Remove Assignments to Parameters - refactor with android studio
1141 ワード
どうですか.
再構築前:
再構築前:
public int discount(int inputVal, int quantity, int yearToDate) {
if (inputVal > 50) {
inputVal -= 2;
}
if (quantity > 100) {
inputVal -= 1;
}
if (yearToDate > 10000) {
inputVal -= 4;
}
return inputVal;
}
:
> ```Java
public int discount(int inputVal, int quantity, int yearToDate) {
int result = inputVal;
if (inputVal > 50) {
result -= 2;
}
if (quantity > 100) {
result -= 1;
}
if (yearToDate > 10000) {
result -= 4;
}
return result;
}
?
- result inputVal, inputVal result 。( android studio cmd+opt+v)
- 。
《 》( )