4 ms·
I've wanted a Result type I could map over in Go as soon as I saw the idea. But someone recently pointed out, without pattern matching and early return, it's ki
by kortex 5y ago
I've wanted a Result type I could map over in Go as soon as I saw the idea. But someone recently pointed out, without pattern matching and early return, it's kind of nerfed. Not sure I totally agree (I think it'd still be awesome to have Result, if only for .map()), but I see their point.
I disagree that it would be without sacrifice. That's kind of the whole point.
Unless I'm missing something, go has iterators with for loops.
- lucian1900 5y agoGo switches with exhaustion checks like in [1] would go a long way. An early return construct would be important as well, though, you're right. Go's for loops can only iterate over builtin types: slices, maps, channels, etc. You can't produce a custom type that is to be iterated over. 1. https://github.com/BurntSushi/go-sumtype https://github.com/BurntSushi/go-sumtype