3 ms·
Yeah I think there's a time and a place for ternaries, but when used correctly they're just so concise. Like if you have super long expressions in your ternari
by skohan 5y ago
Yeah I think there's a time and a place for ternaries, but when used correctly they're just so concise.
Like if you have super long expressions in your ternaries, or you have a bunch of nested/chained ternaries it can be hard to parse, but in a lot of cases it's so nice to get something onto one line instead of needing an if/else
- ensiferum 5y agoYes in c/++ it also allows you to use const. const foo = bar ? 1 : 2; Without ternary you wouldn't be able to use const specifier on foo.