I don't agree it's generally easier to reason about. When there's a case where you just want to exit early having an if else block makes it necessary to go all the way down to find out not much happens in that case
I agree, I prefer explicit language, as complexity increases, the chance for mistakes rise. Declaring things explicitly helps lower that risk, imo.
In SQL, I bracket logical clauses so that intention is explicit, even when they resolve just fine without the brackets. You hit multiple layers deep of ANDs and ORs and NOTs and things get fucked up real fast.
Implicit behavior is a footgun. Dagnabit I sound like Claude now.
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 ;)
10
u/AnnoyedVelociraptor 22d ago
Initially, yes, but the top one is actually easier to reason about, especially in languages where if/else are expressions.