I hate this type of code, there is no reason to an if/else using return statements. To give two good examples of accomplishing the same thing but a little bit clearer,
return $some_condition ? $x : $y;
Or
if ($some_condition) {
return $x;
}
return $y;
I use this last example a lot when I am testing success or failure of subroutines,
return 1 if $self->_condition_1_is_true and
$self->_condition_2_is_true and
$self->_condition_3_is_true; # etc...
return;
The extra else statement sort of implies that something special is going to happen when it is not. Better to get rid of it (as far as return statements are concerned). |