I've never heard arguments against multiple return paths from a bug standpoint. It's usually a performance optimisation standpoint.
I don't really see how it could increase bugs over setting a flag. With a function that sets a flag there's always a risk that you change the flag accidentally after you already hit the value you want.
Which is the same risk as returning earlier than you want, I suppose.
I just find the multiple return paths easier to read, debug and understand, rather than stepping through to trace the value of the flag, you just figure out which return is firing.
The more I write, the more I lean into immutability though. Bugs happen when values can change that shouldn't.
I don't really see how it could increase bugs over setting a flag. With a function that sets a flag there's always a risk that you change the flag accidentally after you already hit the value you want. Which is the same risk as returning earlier than you want, I suppose.
I just find the multiple return paths easier to read, debug and understand, rather than stepping through to trace the value of the flag, you just figure out which return is firing.
The more I write, the more I lean into immutability though. Bugs happen when values can change that shouldn't.