I have a CS degree and I was taught that as well...unfortunately most CS professors don't have much recent industry experience.
Returning early can be very dangerous if you aren't keeping your functions small. If your functions are more than 10-20 lines of code, I'd avoid multiple returns because you'll create a bug factory.
I have a CS degree and I was taught that as well...unfortunately most CS professors don't have much recent industry experience.
Returning early can be very dangerous if you aren't keeping your functions small. If your functions are more than 10-20 lines of code, I'd avoid multiple returns because you'll create a bug factory.
Yes, well said: when it’s dangerous and when it’s not.