On Wednesday, October 19, 2016 at 6:52:30 PM UTC+3, Jan Mercl wrote: > > > On Wed, Oct 19, 2016 at 5:40 PM Viktor Kojouharov <vkojo...@gmail.com > <javascript:>> wrote: > > > That's just a default method implementation. There's nothing inherently > confusing about what gets called. If a concrete implementation exists, that > gets called, otherwise the default one does. > > But to assign something to f (of type Foo) it must implement its method > set, ie. it must have the DoSomething method. So by the above logic the > default method can never get called. >
Not really, as this is all hypothetical, it might be implemented in a way so that any type that wants to satisfy an interface with default methods has to at least implement all non-default ones. That is to say, with the above example interface, any and all types will be able to match, since the interface doesn't define any other methods (in a sense, it turns into interface{}). However, if a type wishes to define any method that has a default implementation, it can do so, and that implementation will be used. > > > -- > > -j > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.