I am learning a language and I was wondering if there is a way to do something like this:
type Foo struct { ... } type Bar struct { Foo ... } func getFoo() Foo { return Bar{...} }
In an object-oriented language, such code should work without problems, but in it it causes an error saying that getFoo() should return an instance of the Foo class.
Is there a way to make polymorphism similar to what I described in Go?
polymorphism oop go
areller
source share