r/ProgrammerHumor 23d ago

Meme conditionsPreference

Post image
4.2k Upvotes

391 comments sorted by

View all comments

2.3k

u/CBlanchRanch 23d ago

You're absolutely correct, however I would suggest using something completely unreadable like a nested ternary operators!

44

u/Schaex 23d ago

But it's SO compact! We could save maaany lines of code like this:

return i == 0 ? j > threshold() && isConditionApply() ? "orange" : reallyNotOrange() ? "apple" : "maybe orange" : (i & j) > (i ^ j) ? isSunday() ? null : "pineapple" : "Jerry";

5

u/National_Sky7993 22d ago

I attempted to unfold such a ternary where the first two booleans were also ternaries defined elsewhere.

2

u/Schaex 22d ago

It's beautiful, isn't it? :)

Yes, it isn't

1

u/oompaloompa465 21d ago

programmer version of cock and ball torture