News for hackers. Stuff that matters.
Re:We Are Sorry to Inform You (2005) by cebert on Saturday June 18, 2022 @08:59AM (#31789439)
I think it depends on the situation, but a single return statement per method does make it a bit easier to read a method and understand flow control.
Re:We Are Sorry to Inform You (2005) by HWR_14 on Saturday June 18, 2022 @10:57AM (#31790359)
At the top of the function, "if [special input] return [special output]" is a great way of handling edge cases
Re:We Are Sorry to Inform You (2005) by Tyr42 on Saturday June 18, 2022 @10:21AM (#31790034)
Really exit can be pretty useful though.

Doing if(condition) return at the start, before it gets going often reduces indentation and how many branches you need to see at once.

But I can agree sneaky returns can bite you sometimes