What it originally meant
The accepted answer's correction is that the entry half is the part people forget, and it was the part that mattered. In assembly you can jump into the middle of a routine, giving it several entry points and making it impossible to reason about what state it starts in. The guidance was against that. It has since been repeated in languages where entering a function anywhere but the top is not even expressible.
The other origin, which is about cleanup
- In a language with manual resource management, returning early skips whatever frees what the function allocated.
- That leaves three options, and none is appealing: duplicate the cleanup before every return, jump to a cleanup block at the end, or route everything through a single exit.
- Single exit was the least bad of the three, which is how it became a rule.
- Languages with automatic cleanup — scope-based destruction, garbage collection, or a construct that guarantees a block runs on the way out — removed the problem the rule existed to work around.
The argument that survives
One answer defended it on grounds unrelated to either origin: a single exit gives you one place to inspect the return value, which makes logging and print-based debugging straightforward. They also supplied the counter, which is that you can wrap the function instead — an inner function doing the work with as many returns as it likes, and an outer one calling it and logging the result once.
What to do with the rule now
- Early returns for guard clauses generally reduce nesting and make the remaining body easier to read.
- Where cleanup must happen, use the language construct that guarantees it rather than controlling the exits by hand.
- The reason to know the history is that the rule is still passed on as style, by people who have never met either of the problems it was written for.