Hacker News new | ask | show | jobs
by Dr_Emann 15 days ago
In only one of those examples do you get a T that's invalid.
3 comments

Some patterns, notably when a reasonable default can be provided, are better handled in Go. In such a case the error handling can often be omitted entirely. Neither Rust or Go recognize this pattern explicitly, however. In Go, as your comment, the function signature doesn't say the result value is actually a valid default when there is an error.
True, Go does require you to follow a convention here (dont use T if err is not nil). In practice it works pretty well, though obviously not bullet proof.

I believe some exceptional languages are similar, like Ruby. If you rescue but dont abort, the variable on the left hand side gets a nil when that may otherwise not be possible. Of course, that is handled cleanly as its own error.

I don't see how. Unless it's the Go example where you get (nil, err)?
yes
yeah that sucks, one of the many reasons I don't like Go error handling.