logoalt Hacker News

kiitoslast Tuesday at 8:49 PM1 replyview on HN

If a function `func foo() (int, error)` returns a non-nil error, then the corresponding `int` is absolutely invalid and should never be evaluated by the caller, unless docs explicitly say otherwise.


Replies

XorNotlast Tuesday at 9:54 PM

And this is why I prefer exceptions.

Errors are common but they are errors: they absolutely represent an exceptional branch of your control flow every time.

It seems reasonable to ask if that int should even be available in the control flow syntactically.

show 1 reply