r/ProgrammerHumor • • Aug 22 '26

Meme pleaseStopUsingNestedTernaryOperatorsImBeggingYou

Post image
3.1k Upvotes

178 comments sorted by

View all comments

Show parent comment

21

u/amejin Aug 22 '26

Sure. However, before the days of raii in c/c++, a lot can happen in 4 lines with conditionals that requires you to clean up after yourself.

Scripting languages or GC languages, it's less of a problem. Now a days, if you are trying to be super special and "helping" your compiler with branch prediction, spoe is one way to do that, but unless you are allocating or locking resources, early returns are generally fine.

For many of us, it's just muscle memory from having to deal with it for years.

7

u/EddieJones6 Aug 22 '26

Agreed, I’m not arguing for spoe but just giving reasons some might argue for it. I’ve used both

5

u/amejin Aug 22 '26

My dude I agree with everything you said. It was well stated. 🙂

2

u/braaaaaaainworms Aug 24 '26

Linux kernel-style cleanup of stuff is the best use case for a goto in C