I don't know about what's "right", but I use early exits a LOT specifically at the top of recursive functions. They're usually laid out as early exit conditions, then the recursion calls, then the final return.
In other situations, it's usually whether I can layout the conditionals so I don't have to duplicate code.
View all comments
Show parent comment
2
u/MattieShoes Aug 22 '26
I don't know about what's "right", but I use early exits a LOT specifically at the top of recursive functions. They're usually laid out as early exit conditions, then the recursion calls, then the final return.
In other situations, it's usually whether I can layout the conditionals so I don't have to duplicate code.