'has_dinosaurs' was written according to PBP, and therefore returns either '1' or the default value of return.
There is no default value of return. But if you want to say that in your code there's a bare return, it doesn't return anything, i.e not even a single 'undef' which would be a one element list in list context.
If you want the value for the key 'stop_dinosaurs' explicitly set, you could say
but if you want to skip that key/value pair completely if $park->has_dinosaurs returns a false value, thenstop_dinosaurs => $park->has_dinosaurs ? 1 : 0,
(stop_dinosaurs => 1 ) x ! ! $park->has_dinosaurs,
would make the list (stop_dinosaurs, 1) disappear, if $park->has_dinosaurs evaluates to false. See Binary "x" in perlop.
In reply to Re: return explicit undef - Best Practices?
by shmem
in thread return explicit undef - Best Practices?
by Boldra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |