Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
A coworker passed on the following bit of code, which, as far as I can tell, does nothing:
$x ||= 0;
Any ideas on how or why something like Or, Or, Equals Zero would be used?$x = -1; $x ||= 0; print $x; -1 $x = 0; $x ||= 0; print $x; 0 $x = 2; $x ||= 0; print $x; 2 $x = 3; $x ||= 0; print $x; 3 $x = 123132; $x ||= 0; print $x; 123132
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Or, Or, Equals Zero, $x ||= 0
by eric256 (Parson) on Nov 27, 2007 at 23:08 UTC | |
Re: Or, Or, Equals Zero, $x ||= 0
by graff (Chancellor) on Nov 28, 2007 at 02:09 UTC | |
by tye (Sage) on Nov 28, 2007 at 05:56 UTC | |
by Erez (Priest) on Nov 29, 2007 at 11:01 UTC | |
Re: Or, Or, Equals Zero, $x ||= 0
by FunkyMonk (Chancellor) on Nov 27, 2007 at 23:24 UTC | |
Re: Or, Or, Equals Zero, $x ||= 0
by markkawika (Monk) on Nov 28, 2007 at 00:33 UTC |
Back to
Seekers of Perl Wisdom