3 ms·
The second you add a tenary operator people are gonna nest them, but the same is true for if/switch/match expressions unfortunately. I don't think they meant st
by lyu07282 2y ago
The second you add a tenary operator people are gonna nest them, but the same is true for if/switch/match expressions unfortunately. I don't think they meant stupid literally, it's more like KISS philosophy applied to language design for maintainablity/readability/code quality reasons. Google employs some of the smartest programmers in the world.
- School-Cotton 2y agoNesting them is not so bad if the syntax makes it obvious what the precedence is, which isn't true of C, but is of Rust for example. Anyway, complicated code should be avoided whenever possible, true, but banning the ternary operator (and similar constructs like match/switch statements as expressions) does nothing to make code simpler. It just forces you to transform let x = (some complicated nested expression); into var x; // (some complicated nested tree of statements where `x` is set conditionally in several different places)