9 ms·
Early return makes it easy to reason that the rest of the code in the function is unrelated to whatever you're checking for right now. Having multiple exit poin
by syockit 5y ago
Early return makes it easy to reason that the rest of the code in the function is unrelated to whatever you're checking for right now. Having multiple exit points in a function is not the end the world.
If you need to print()/log() before return, then just replace them with goto (if your language supports it). After debugging if you have no more use for print()/log() statements you can remove just those statements and keep goto as it is.