Hacker News new | ask | show | jobs
by speedyapoc 1894 days ago
I recall this pattern being taught in my first year or two of my computer science degree. Emphasizing only one return statement per function, utilizing a shared return variable.

I much preferred (and still greatly prefer in industry) the pattern of exiting the function as soon as possible.

2 comments

It's like "goto considered harmless" -- structured code to max, to the point of unreadability. Dogmatism has drawbacks.
Same here.

Returning and throwing quickly and strict.