in reply to Re^6: Short form (ternary) if else
in thread Short form (ternary) if else
1 ? $x=1 : $x=0
really means
(1 ? $x=1 : $x)=0
which is then the same as
($x=1)=0
which is why $x becomes 0.
You can use assignments within ? :, you just need to parenthesize them
1 ? $x=1 : ($x=0)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Short form (ternary) if else
by Riales (Hermit) on Feb 08, 2012 at 23:43 UTC |