in reply to Re^4: What could make "()" a good value for boolean false?
in thread What could make "()" a good value for boolean false?
Yes (although strictly speaking, that's an array in scalar context), and also
$ perl -wMstrict -le 'sub foo { print wantarray?"list":"scalar"; return 0; }; print( (()=foo()) ? "true" : "false" );' list true
(although strictly speaking, that's a list assignment in scalar context). But there's also perlsyn (emphasis mine):
The number 0, the strings '0' and "", the empty list (), and undef are all false in a boolean context. All other values are true.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: What could make "()" a good value for boolean false?
by ikegami (Patriarch) on Apr 01, 2016 at 15:55 UTC |