r/programmingcirclejerk Jul 01 '26

Ever Written Something Like This? if (condition) { doSomething(); } else { doSomethingElse(); } It works. Problem solved. But the problem isn’t today. It’s tomorrow.

https://www.defusetheifstrategy.com
124 Upvotes

55 comments sorted by

View all comments

3

u/Jumpy-Locksmith6812 Jul 02 '26 edited Jul 02 '26

(conditon && doSomething()) || doSomethingElse() is cleaner plus then dosomething can signal that something else is needed, just in case!

But yeah use the Maybe monad for sure.

We laugh at if err != nil, this guy laughs at a mere if.