in reply to Why does the Perl conditional operator not do what I expect?
($condition) ? ($a=2) : ($a=3);
btw from previous experience, I found it quite difficult to super search or google for advice on this construct, as most search engines do not recognise most punctuation, and I for one did not know it was called 'ternary ?'.
update: p.s. in response to linuxer, say you wanted to do $condition ? $a=2 : $b=3, would ($condition) ? ($a=2) : ($b=3) then be the correct/advisible way to do it?
cheers
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why does the Perl conditional operator not do what I expect?
by AnomalousMonk (Archbishop) on Apr 20, 2009 at 13:01 UTC | |
|
Re^2: Why does the Perl conditional operator not do what I expect?
by Bloodnok (Vicar) on Apr 20, 2009 at 11:04 UTC | |
by roboticus (Chancellor) on Apr 20, 2009 at 12:23 UTC | |
by why_bird (Pilgrim) on Apr 20, 2009 at 11:09 UTC |