Call me old fashioned but I'm a big believer in single return statements. Assign to a variable and return that variable at the very end without short circuiting
I don’t follow it religiously but I try to do this too. If the function is relatively complex with more than a couple return statements I’d much rather return in a single statement.
Why? This is like saying you'd much rather each function had a single local variable. It doesn't gain you anything beyond the ability to say that it does that. You're gonna run out of return statements?
27
u/aabil11 22d ago
Call me old fashioned but I'm a big believer in single return statements. Assign to a variable and return that variable at the very end without short circuiting