5 ms·
I don't necessarily think what you don't like is related to early returns because the code in the article could be written like if (!status.hasInsurance()){
by thdc 6y ago
I don't necessarily think what you don't like is related to early returns because the code in the article could be written like
if (!status.hasInsurance()){
return 1;
}
if (status.hasInsurance() && status.isTotaled()){
return 10000;
}
// ...
to be explicit about the conditions. Or without early returns but with still the same issue:
if (!status.hasInsurance()) {
amount = 1;
} else if (status.isTotaled()) {
amount = 10000;
}
// ... return amount