But I feel like there's situations where it's arguably clearer than the alternative.
Other commenters have mentioned the functional angle, and that's really it. In many (all?) the languages that have the ternary operator if is a statement (rather than an expression). Make if an expression and ternary has no place in the world:
let a = if cond { true_value } else { false_value };
Note, I say we don't need the ternary because it can be replaced with general purpose binary operators. I'm not suggesting to get rid of the functionality, that'd be crazy-talk.
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.
I agree with with all your points.
But I feel like there's situations where it's arguably clearer than the alternative.
Other commenters have mentioned the functional angle, and that's really it. In many (all?) the languages that have the ternary operator
if
is a statement (rather than an expression). Makeif
an expression and ternary has no place in the world:Note, I say we don't need the ternary because it can be replaced with general purpose binary operators. I'm not suggesting to get rid of the functionality, that'd be crazy-talk.