3 ms·
> It still amazes me how they can believe that putting all the guards in tens of nested ifs can be saner than a few extra returns at the top. On the other hand
by augustk 3y ago
> It still amazes me how they can believe that putting all the guards in tens of nested ifs can be saner than a few extra returns at the top.
On the other hand, if you have ten early returns your function should most likely be split into smaller functions anyway. The advantage of sticking to structured programming is that it becomes obvious when it's time to do so.
Another advantage of pure structured programming (which implies a single exit point) is that you can easily add post-conditions to your functions, i.e. assertions which must hold true before the execution returns to the caller.