Answer the question
In order to leave comments, you need to log in
How to make interface for type hierarchy?
There are two types in the project - "group" and "element". The group has a "get certain items" method. We get something like this:
type element struct {}
func (el *element) doA() int {...}
func (el *element) doB() int {...}
type group struct {
elements []*element
}
func (g *group) getElements() []*element {...}
type AElement interface {doA() int}
type BElement interface {doB() int}
type AGroup interface {
getElements() []AElement
}
type BGroup interface {
getElements() []BElement
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question