An elision would cause its behavior to deviate from that of a ternary operator, though: if b is null/none then true ? b | 3 would return 3 whereas the ternary operation true ? b : 3 returns null.
That is the true strength of the ternary operator: to choose between two paths before evaluating them. All binary operators always have to evaluate one of their operands first.
That is true. And I think for that reason it'd make sense to raise an error if the true_value is an optional. It'd lead to a potential ambiguity in what is desired.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
An elision would cause its behavior to deviate from that of a ternary operator, though: if
b
is null/none thentrue ? b | 3
would return 3 whereas the ternary operationtrue ? b : 3
returns null.That is the true strength of the ternary operator: to choose between two paths before evaluating them. All binary operators always have to evaluate one of their operands first.
That is true. And I think for that reason it'd make sense to raise an error if the true_value is an optional. It'd lead to a potential ambiguity in what is desired.