3 ms·
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.
by cebert 4y ago
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.
- Tyr42 4y agoReally 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
- HWR_14 4y agoAt the top of the function, "if [special input] return [special output]" is a great way of handling edge cases