2 ms·
Plus is a bad example because you can't do that in Go, but I understand the question. Basically, you don't do that in Go. Go has interfaces, but they're implem
by vectorjohn 11y ago
Plus is a bad example because you can't do that in Go, but I understand the question.
Basically, you don't do that in Go. Go has interfaces, but they're implemented implicitly. So rather than "I get an object", you say, "I get an object that implements interface X", and you use whatever methods X has.
That just means its up to you to name interfaces in a reasonable way. Which is one down side - if you have an "Add" method, it's back to your question about what it means to add, depending on the implementation.
Nothing does this as well as Haskell as far as I can tell.