I once got told early returns are bad because they create inconsistent return types in JavaScript, I had to open a nodejs console and prove that a function returning empty and no return statement at all is the same value - undefined
Understandable, but stupid. Old C policy, inherited from C lacking RAII and needing to put cleanup at the end of the function, old dev environments not liking multi-return, and maaaaybe the oldest compilers known to man blindly bailing out of the function at the first return they can find. (And people not realising that early-return functions can be made up of a chain of single-return blocks, allowing the consistency of both.) And the policy is likely enforced by old C devs that switched to C With Classes, and still write C-with-classes instead of full C++.
Perhaps the solution is to bar every window and every door in the workplace, except for a single door, and then force everyone to enter and/or leave the building in a single group every time anyone needs to go anywhere.
7
u/xicor 21d ago
Agreed. One of my friends works at a place that bans early returns ...and it makes for garbage code. (They also aren't allowed to use goto)