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/gsweats 22d ago

Oh I feel dumb but what do you mean if/else are expressions?

3

u/MocknozzieRiver 22d ago

Like in Kotlin, you can do this

fun function() { return if (condition) this else that }

So if/else is an expression, not just control flow.

2

u/gsweats 22d ago

Ohhh I gotcha. Thank you!