|
|
|
|
|
by epidemian
3622 days ago
|
|
> Am I alone and thinking that it's a little bit hypocritical to specifically add functionality to your language if you don't want people to use it? It's just a change to make the language more consistent. `a, b = something` already worked as an expression in most places, so it makes sense that it should be allowed on `if` conditions too. Before 2.4: > if (a, b = nil) then :foo else :bar end
SyntaxError: (eval):2: multiple assignment in conditional
So instead of having that special syntax error, and probably needing a justification for it, Ruby 2.4 makes `a, b = something` a valid expression there and removes an edge case.That you probably shouldn't use multiple assignment on an `if` condition is a separate issue. It's just a preference, and it follows the same logic of avoiding assignments on conditional expressions in general. |
|