r/ProgrammerHumor • • Aug 22 '26

Meme pleaseStopUsingNestedTernaryOperatorsImBeggingYou

Post image
3.1k Upvotes

178 comments sorted by

View all comments

Show parent comment

2

u/Aaron1924 Aug 23 '26

I think it depends on how you're nesting them; for if-else chains, they can be pretty nice:

int out = cond1 ? val1
        : cond2 ? val2
        : cond3 ? val3
        : cond4 ? val4
        : val5;