in reply to variable set to 0 ? 0 : 1
By operator precedence, return $status == 0 ? 0 : 1; is treated as return ($status == 0) ? 0 : 1; which is a stylistic way of saying "return 0 if $status is 0, otherwise return 1".
Other ways to write this include
which is what you might expect a junior C programmer to write, orif ( $status == 0 ) { return 0; } else { return 1; }
which you might see a Perl programmer write if they eschew the trinary operator.return 0 if $status == 0; return 1;
|
|---|