News for hackers. Stuff that matters.
Re:Reflections on 10k Hours of Programming by skohan on Friday August 06, 2021 @11:58AM (#28088957)
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

Re:Reflections on 10k Hours of Programming by ensiferum on Friday August 06, 2021 @05:01PM (#28092687)
Yes 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.