in reply to Re: Re: if-else vs. tertiary effieciency?
in thread if-else vs. tertiary effieciency?

Think of it as:
print ( $boolean ? $true_value : $false_value );
or in your terms:
print ( if($var}{ 'yes' }else{ 'no' } );
I like this less because it is pseudo-code that looks
much like code. So it seems to imply many things that
aren't true. The conditional operator is only an
operator not a statement.

Replies are listed 'Best First'.
REł: if-else vs. tertiary effieciency?
by blaze (Friar) on Sep 15, 2002 at 05:31 UTC
    so the print isnt part of the ?: in fruiture's example...if thats the case then it makes beautiful sense and i cant believe i didnt see it before, if thats not the case im a little more lost than i was to begin with :)

    ill be sure to ++ you when i get my next set of votes ;)
      If in doubt, deparse:
      $ perl -MO=Deparse,-p -e'print $var ? "yes" : "no";' print(($var ? 'yes' : 'no')); -e syntax OK
      The ternary operator here has a higher precedence than the print that works as a list operator, so Perl does the right thing.

      Makeshifts last the longest.