3 ms·
Yeah. The example is not very good, as it would probably be better to write as switch expression. But on a complex function, returning early can avoid the need
by epidemian 14y ago
Yeah. The example is not very good, as it would probably be better to write as switch expression. But on a complex function, returning early can avoid the need to retain a lot of context in your head while reading that code. I find it especially helpful for returning/throwing on error conditions or breaking out of recursion.