(Randal L. Schwartz) schreef:

> There's an &&=, and I thought I'd never use it.
>
> However, one day, I realized that I needed to "normalize" the
> "true/false" value of a variable, because I wanted to reduce all
> possible true/false values to just 1/0 for easy operations in the
> next step of the program.
>
> And I came up with this:
>
>         $variable ||= 0; # all false values become 0
>         $variable &&= 1; # all true values become 1
>
> OK, so it's weird. :)  I could have just as easy had said:
>
>         $variable = ($variable ? 1 : 0);
>
> But the actual case of needing &&= was cool.

And q{0 but true} and q{0e0} and q{0e1} etc. become 1 as well.

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to