4 ms·
Same here. The Go approach is easy to read and eye compile. I can't stand exceptions now.
by powerslacker 4y ago
Same here. The Go approach is easy to read and eye compile. I can't stand exceptions now.
- philosopher1234 4y ago>eye compile i like this phrase
- eweise 4y agoIt still suffers from being returned as a separate value so not easy to chain methods together.
- robotastronaut 4y agoMethod chaining, while possible, isn’t something I’d say is really encouraged in Go. Returned values should be handled explicitly. There are plenty of cases where it could be fine, but if a function can error, you wouldn’t want to chain anyways.
- closeparen 4y agoYes, you would. “Chain all these methods and stop when you get to the first error” is an extremely common idiom. People write it all the time in lots of different languages. Go is unusual in that you have to spell it out.
- robotastronaut 4y agoRight, I know. You’re not wrong. I was meaning you wouldn’t want to do it in Go because it’s not idiomatic (and likely impossible as discussed). I use it all the time in other languages and don’t mind exception patterns, but method chaining feels very out of place when reading Go code.