in reply to Re: "x ? y : z" notation
in thread "x ? y : z" notation
$x == 1 ? print "x was '1'" : print "x was something else";
While that's technically correct it doesn't take advantage of the fact that the ternary operator has a return value; whatever expression is evaluate after the ?.
See another adaptation that takes advantage of this feature.
print( "x was " . $x == 1 ? "'1'" : "someting else" );
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: "x ? y : z" notation
by rovf (Priest) on Mar 26, 2009 at 09:09 UTC | |
by poolpi (Hermit) on Mar 26, 2009 at 10:31 UTC |