develooper Front page | perl.fwp | Postings from December 2001

Re: tri-state flags

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
December 5, 2001 01:56
Subject:
Re: tri-state flags
Message ID:
20011205045634.M14333@blackrider
On Wed, Dec 05, 2001 at 10:43:14AM +0100, Sven Neuhaus wrote:
> Looks like "~" doesn't trigger a warning on undef.
> 
> So
> ~$a ? $a ? 3 : 2 : 1
> 
> will yield 3 for true, 2 for false, 1 for undef.

That's no good, repetition of the expression is a no-no.

    Note that "$flag" may well be an expression, so repetition as in
    the next, is not good:

            defined $flag && !$flag



-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl Quality Assurance	    <perl-qa@perl.org>	       Kwalitee Is Job One
But I wore the juice!

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About