Re:Go proposal: Leave “if err != nil” alone?
by basic6 on Friday June 28, 2019 @01:28PM
(#20306730)
Go's opinionated, three line if is part of the problem. A single line if or ternary operator would reduce the line noise.
[ Parent
| on HN ]
Re:Go proposal: Leave “if err != nil” alone?
by __david__ on Friday June 28, 2019 @01:54PM
(#20307025)
Yeah, it's quite common in C to just do:
if (error) return error;
It's the same style as go, but so much more compact. If `go fmt` were to render the error boilerplate as if err { return err }
…instead of the three line boilerplate it insists on, then it would go a long way.That said, I still support `try()`. It looks good to me, especially coming from Rust.