upvote
Guard clauses are things that return early for trivial or problematic cases. Like https://en.wikipedia.org/wiki/Guard_(computer_science)#Flatt...

They're one of those good practices that look like bad practice to everyone who just got a CS degree. Seems ex-students are unsettled by asymmetry or want to minimize the number of return statements.

reply
Particularly for high performance code when branch prediction is taken to account
reply
Swift explicitly has a guard statement for this. Rust's let .. else { ... } is also very similar.

https://docs.swift.org/latest/documentation/the-swift-progra...

reply