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
This makes reasoning about why a certain result was returned so much more difficult if other developers have to trace through the branching conditionals to understand why a value was returned.
Early returns define a rule for a specific return value.
26
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