2 ms·
But you can define an interface that matches someone else's types and then attach the method to it. The main similarity I was going for was the way that an int
by brightball 10y ago
But you can define an interface that matches someone else's types and then attach the method to it.
The main similarity I was going for was the way that an interface fits anything that matches it, rather than being directly implemented by the type. A method could be attached to an interface that matches a struct with two specific variables while Elixir could define a pattern on a function that worked for any struct that contained those two variables.
They are both doing a similar thing a different way.
- riwsky 10y agoThe confusion with GP might be that you can't, in fact, define an interface and attach methods to it. More info @ https://golang.org/ref/spec#Method_declarations https://golang.org/ref/spec#Method_declarations