3 ms·
> What does it add, or what problem is it trying to solve? In Java, if you get a type from a library, and it doesn't implement a particular interface, you're s
by wtetzner 7y ago
> What does it add, or what problem is it trying to solve?
In Java, if you get a type from a library, and it doesn't implement a particular interface, you're stuck. You have to wrap it up in some intermediate type. It's useful to be able to use types that don't know about a particular interface even if they happen to conform to that interface.
However, I would agree that it would be useful to be able to specify which interfaces you intend a particular type to implement. (Or maybe Go allows this? I'm just talking about duck typing here, as I don't know Go very well.)