in reply to C-like Function Prototypes
in thread sub ($self,$var,@arr) {}
$y ||= 10;
FWIW, be careful with that. Using ||= is one of my favorite ways to write fluent Perl, but it just got me burned a few days ago.
The problem was that the $y I was initializing was a numeric value - but zero was an acceptable value.
In that case, my ||= was overriding the supplied value of zero, which tested false against the operator. In the example here, providing an argument of 0 for $y will result in $y getting 10, not zero.
Oops. :-)
Peace,
-McD
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Careful...
by arturo (Vicar) on Feb 09, 2001 at 22:11 UTC |