Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: One out of three ain't bad (order)

by Dr. Mu (Hermit)
on Oct 23, 2005 at 04:21 UTC ( [id://502286]=note: print w/replies, xml ) Need Help??


in reply to Re: One out of three ain't bad (order)
in thread One out of three ain't bad

Or, shorter:

if (2 == !$x + !$y + !$z) {

Replies are listed 'Best First'.
Re^3: One out of three ain't bad (order)
by mrborisguy (Hermit) on Oct 24, 2005 at 04:51 UTC

    Which seems to work right now, since you've seen the progression of what came before. But in 2 months, I can imagine you thinking, "Now why in the world is there a two in there... I must want two of them to be true" on your first look while skimming your code.

        -Bryan

      True enough. I suppose what's lacking is a commonly-accepted idiom for Boolean conversions. We have 0+ for numeric conversions; so perhaps !! wasn't so bad after all, even though two operations are implied (unless the compiler optimizes them out). 0|| and 1&& would also work.

        No, 0||$x is just $x, not "Booleanized" $x. perl -le"print 0||5" prints 5 not 1 and perl -le"print 1&&@ARGV" x y z prints xyz.

        - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://502286]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-18 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found