3 ms·
So subtyping automatically happens for all members of a struct? I'm not sure I like that but I guess I'd have to see how well it works in practice.
by eco 12y ago
So subtyping automatically happens for all members of a struct? I'm not sure I like that but I guess I'd have to see how well it works in practice.
- 4ad 12y agoNo, it only happens if you embed the type, a.i. the member is anonymous. http://golang.org/doc/effective_go.html#embedding http://golang.org/doc/effective_go.html#embedding http://golang.org/ref/spec#Struct_types http://golang.org/ref/spec#Struct_types Note that there's also interface embedding which is a different thing.
- eco 12y agoAh, that makes a lot more sense. Thank you for explaining.