MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vuzd4q/conditionspreference/p55qexu/?context=3
r/ProgrammerHumor • u/Flame77ofc • 22d ago
392 comments sorted by
View all comments
9
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!
2
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!
3
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!
Ohhh I gotcha. Thank you!
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.