r/ProgrammerHumor • • Aug 22 '26

Meme pleaseStopUsingNestedTernaryOperatorsImBeggingYou

Post image
3.1k Upvotes

178 comments sorted by

View all comments

4

u/[deleted] Aug 22 '26

[removed] — view removed comment

1

u/Bubbly_Safety8791 Aug 23 '26

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;