3 ms·
Where exactly does the struct pair implement the Stringer interface? Is it when the String method was added to it? What if you have interfaces with similar name
by emehrkay 13y ago
Where exactly does the struct pair implement the Stringer interface? Is it when the String method was added to it? What if you have interfaces with similar names?
- thisishugo 13y ago>Is it when the String method was added to it? Yes, that is how you satisfy an interface in Go. >What if you have interfaces with similar names? The problem of interfaces with similar names is actually no different than the problems of, for example, packages or functions having similar names. It's down to you to avoid naming things in a confusing manner.
- ominous_prime 13y agoThere is no "implements" in go. A type either provides the methods to satisfy an interface, or it doesn't. The name of the interface doesn't matter, and it can satisfy an many interfaces as it wants.