3 ms·
I think there are two situations where the return early and nesting if options come into play, and each situation warrants a different strategy: 1. You are gua
by beaconstudios 8y ago
I think there are two situations where the return early and nesting if options come into play, and each situation warrants a different strategy:
1. You are guarding for errors or invalid states - you should use early returns or thrown exceptions because these are unexpected states.
2. Your business logic has to branch - you should use a nesting if (or various other options that aren't in scope here, like double dispatch, pattern matching or polymorphism).