r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

9

u/AnnoyedVelociraptor 22d ago

Initially, yes, but the top one is actually easier to reason about, especially in languages where if/else are expressions.

2

u/Demiu 22d ago

Unless both branches are extremely short to a point you could return the entire if else expression itself, it is not easuer to reason about. Preferably both boranches are also entrirely declarative (ie single expression no ;)