Hacker News new | ask | show | jobs
by elvlysh 451 days ago
So you would prefer to write match result => error instead of if err != nil? Excuse me for not being convinced that this isn't just fussing over syntax.
3 comments

If a language supports Result types, that usually means it also comes with some kind of syntax to use it. Check out some Rust code (or Haskell, Scala, F#, ...) and you will find that in those languages you barely match on the result because you don't have to. Whereas you have to do "if err != nil" in golang all the time.
It isn’t just fussing over syntax, but that would require you actually being curious enough to learn why instead of needing to dismiss people’s valid critiques of out hand.
It's not just syntax, a sum type forces checking for the error whereas a product type does not, so it's a semantic distinction too