I have two interfaces written in go
, one which is a subset of the other
type x interface {
a()
}
type y interface {
a()
b()
}
I also have a struct that has methods as such
type z struct {
some string
}
func (s z) a() {
// do stuff
}
func (s z) b() {
// do stuff
}
I have a few questions regarding this, namely:
- Am I right to say that z implements both x and y?
- What is the OOP concept for one struct implementing multiple interfaces in this way?
I tried asking a few colleagues, who seem to lean towards polymorphism
as the answer although they are not too sure. The wikipedia entry for polymorphism says that it "is the provision of a single interface to entities of different types", but this feels like the direct reverse to me. I have also found in other sources (eg. this) that Go is "not really a OOP language".