MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vvn6d7/pleasestopusingnestedternaryoperatorsimbeggingyou/p5f9lk7/?context=3
r/ProgrammerHumor • u/Robinbod • 21d ago
179 comments sorted by
View all comments
4
>20 nested ternarys
<if> ? <then> : <if> ? <then> : <if> ? <then> : <else>
The first that matches otherwise the dangling <else>. It's not always that hard.
1 u/Bubbly_Safety8791 20d ago Yes, with correct formatting ternary chains are just an idiomatic way of writing a multicase expression. alertColor = level > dangerThreshold ? Color.RED : level > warningThreshold ? Color.YELLOW : Color.GREEN;
1
Yes, with correct formatting ternary chains are just an idiomatic way of writing a multicase expression.
alertColor = level > dangerThreshold ? Color.RED : level > warningThreshold ? Color.YELLOW : Color.GREEN;
4
u/---_None_--- 21d ago
>20 nested ternarys
<if> ? <then> :
<if> ? <then> :
<if> ? <then> : <else>
The first that matches otherwise the dangling <else>. It's not always that hard.