3 ms·
> If you test-and-return after every call, your function has multiple exit points and is far less maintainable. There is nothing wrong with multiple exit point
by EdiX 13y ago
> If you test-and-return after every call, your function has multiple exit points and is far less maintainable.
There is nothing wrong with multiple exit points as long as:
a. the language has a mechanism for scoped resource allocation (ie. defer, finally, with, unwind-protect or "RAII")
b. the early exit doesn't happen in the middle of a long and complex function
- azth 13y ago> a. the language has a mechanism for scoped resource allocation (ie. defer, finally, with, unwind-protect or "RAII") Just being pedantic here. RAII is more specific than the defer statement that Go offers. Strictly speaking, defer is not RAII.