In addition to Zaxos correct idiom it is useful to note you can use do{} in a ternary op which lets you say do:
$condition ? do{ $a = $b } : do { $c = $d }; $condition ? do_stuff() : do{ $stuff = NOT_DONE };
ie mix assignments to different vars, assignment and function call etc. This is mostly useful if you are using it as a shortform idiom for if/elseif..... If you are just assigning different values to a variable based on some condition Zaxos $var = $cond ? $val1 : $val2; is the way to go.
cheers
tachyon
In reply to Re: ?: conditional operators appear to fail
by tachyon
in thread ?: conditional operators appear to fail
by landau351
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |