in reply to Re: variable set to 0 ? 0 : 1
in thread variable set to 0 ? 0 : 1
... if you mean to return "false", the Perlish way is to return an empty list. This is because by returning 0 you return a single-element list, which evaluates to true in list context.
I feel the risk of that happening is mildly exaggerated. :-)
If you directly evaluate the return value of the sub for truth you supply the sub a Boolean context, and there will be no problem.
To run into problems, you'd have to call the sub in a list context, save the list of 1 return value and then evaluate that in scalar context. But then the problem would be evaluating a list in scalar context when you didn't mean to.
— Arien
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: variable set to 0 ? 0 : 1
by Aristotle (Chancellor) on Sep 06, 2002 at 13:46 UTC |