type HorsePlay interface {
Neigh()
}
type SomeClass[T HorsePlay] struct {
players []T
}
func (sc SomeClass[T]) NeighAll() {
for _, p := range sc.players {
p.Neigh()
}
}
type Horse struct{}
func (h Horse) Neigh() {
fmt.Println("neigh!")
}
func main() {
sc := SomeClass[Horse]{players: []Horse{{}, {}, {}}}
sc.NeighAll()
}