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

Re: tri-state flags

Thread Previous | Thread Next
From:
Bernie Cosell
Date:
December 5, 2001 04:42
Subject:
Re: tri-state flags
Message ID:
3C0DD040.5841.26C3F02@localhost
On 5 Dec 2001, at 11:34, abigail@foad.org wrote:

> On Wed, Dec 05, 2001 at 05:11:43AM -0500, Michel Lambert wrote:
> > > defined $flag && !$flag
> > > So, who does better?
> > 
> > 
> > defined ($var = $flag) && !$var
> > 
> > $flag is only evaluated once. :)
> 
> 
> But Bart said he wanted to test for 0. The test above, and several of
> the other proposals don't distinguish between 0 and the empty string.

Well, what I thought he actually said was that the flag had one of the values 
1,0,undef.

I suppose you could then consider it a quinary flag with two other 
hidden/illegal values:  true but not 1, and false but not-numeric-zero and so 
in the '0' have to actually test for "was it really ZERO" rather than the flas-
but-not-numeric-zero case.

but from what he said, I'd think that bumming off of concluding "It is not 
undef and not true" implies "it must have been zero" is legit within the 
parameters of the challenge, no??

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
mailto:bernie@fantasyfarm.com     Pearisburg, VA
    -->  Too many people, too few sheep  <--          

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