|
|
|
|
|
by EdiX
4703 days 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 |
|
Just being pedantic here. RAII is more specific than the defer statement that Go offers. Strictly speaking, defer is not RAII.