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