3 ms·
In Python, the side effects were considered so nasty that they finally added ternary operators in 2.6. The syntax goes like: x = 'foo' if foo else bar whi
by anthonyb 16y ago
In Python, the side effects were considered so nasty that they finally added ternary operators in 2.6. The syntax goes like:
x = 'foo' if foo else bar
which is at least more readable than the C/PHP/Ruby equivalent.
- steveklabnik 16y agoYou can do x = if foo then 'foo' else 'bar' end in Ruby, if you'd like.