7 ms·
> having positive branching first This is advice I've never seen or received. It's always been the latter, exit early, etc. Languages like Swift even encode th
by satyanash 1y ago
> having positive branching first
This is advice I've never seen or received. It's always been the latter, exit early, etc. Languages like Swift even encode this into a feature, a la if guards.
- Zanfa 1y agoPositive branch first is good advice when both branches are roughly even in terms of complexity. If the negative branch is just a return, I’d bail early instead. Negative first makes else-branches double negative which reads weird, eg. if !userExists {…} else {…}