4 ms·
Quick example on the playground, if this is what you were asking about: http://play.golang.org/p/zShJKp0t3n http://play.golang.org/p/zShJKp0t3n
by cjslep 12y ago
Quick example on the playground, if this is what you were asking about: http://play.golang.org/p/zShJKp0t3n http://play.golang.org/p/zShJKp0t3n
- eco 12y agoSo 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.