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

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        

Replies are listed 'Best First'.
Re^6: One out of three ain't bad (! !!)
by Dr. Mu (Hermit) on Oct 26, 2005 at 01:59 UTC
    So, once again in Perl,
    $conjecture->obviously_so == 1 && $conjecture->true == 0
    Thanks, tye, for testing something I should've! (tho' the logic of Boolean diadics not returning Boolean values escapes me...)
      (tho' the logic of Boolean diadics not returning Boolean values escapes me...)

      It allows idioms such as:

      $hostname ||= 'localhost';

      Since that is just short for:

      $hostname= $hostname || 'localhost';

      it'd set $hostname to just 'true' if Boolean operators returned Boolean values. Of course, the above is short-hand for:

      $hostname= 'localhost' if ! $hostname;

      but the first form is the only one that manages to not repeat $hostname, which can be quite an advantage in some cases, or across a bunch of similar cases. And there are other similar idioms that are useful because of this property.

      In any case, it is quite "Perlish".

      - tye