3 ms·
While sometimes it would be nice to have a source-code confirmation, that struct Foo implements the interfaces Bar and Baz, there is one huge benefit of not req
by _ph_ 6y ago
While sometimes it would be nice to have a source-code confirmation, that struct Foo implements the interfaces Bar and Baz, there is one huge benefit of not requiring to declare the interfaces a struct implements: a struct can implement an interface the struct creator doesn't know about. So you can design new interfaces, which for example structs from the standard library or any third party library happen to implement. You don't have to change the original libraries for that. This is quite a benefit for modularity.