4 ms·
Various C/C++ programming safety standards (such as MISRA C), specify a single return only. [0] is probably the best defense of the position I could find quick
by photojosh 5y ago
Various C/C++ programming safety standards (such as MISRA C), specify a single return only.
[0] is probably the best defense of the position I could find quickly, but the example used is convoluted, and very much "look what happens when you allow multiple returns".
I personally like to use early returns as guard statements when I'm doing precondition checking or on errors.
[0] https://spin.atomicobject.com/2011/07/26/in-defence-of-misra/ https://spin.atomicobject.com/2011/07/26/in-defence-of-misra...