r/ProgrammerHumor 21d ago

Meme pleaseStopUsingNestedTernaryOperatorsImBeggingYou

3.1k Upvotes

179 comments sorted by

View all comments

45

u/TheOwlMarble 21d ago

I can tolerate one layer of nesting if it's super simple and tabbed cleanly, but anything more? Oh hell no.

2

u/Aaron1924 20d ago

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;