in reply to Re: Conditional style (if, &&) query
in thread Conditional style (if, &&) query
The '1' is a perl-ism. Perl will return the value of the last true value in the boolean. To prevent people from taking shortcuts and expecting the sub to return false or the value of $red_button_pressed or $massive_failure we return one. Sooner or later it will no longer return what they think it does, and their code will melt (see also bitrot).# check for a pilot action if ($red_button_pressed) { eject_seat(); } eject_seat() if $massive_failure; # check for exceptional behavior # sub returns true/false if the seat was ejected return $red_button_pressed && $massive_failure && 1; # fixed to put th +e && 1 on the end, in the original it was at the start
-jackdied
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Conditional style (if, &&) query
by blakem (Monsignor) on Oct 17, 2001 at 03:21 UTC |