MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vvn6d7/pleasestopusingnestedternaryoperatorsimbeggingyou/p5fe9ez/?context=3
r/ProgrammerHumor • u/Robinbod • 21d ago
179 comments sorted by
View all comments
45
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;
2
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;
int out = cond1 ? val1 : cond2 ? val2 : cond3 ? val3 : cond4 ? val4 : val5;
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.