4 ms·
You could equally say that just because a class declares that it "implements" an interface, it doesn't mean it does what you would expect from it. In practice,
by msbarnett 14y ago
You could equally say that just because a class declares that it "implements" an interface, it doesn't mean it does what you would expect from it.
In practice, there is no language that can save you from people with malicious intent to confuse you.
In practice, this is rarely an issue.
- pjmlp 14y agoThere is a big difference. When a developer makes a class implement an interface s/he signing a contract thus validating assumptions. When a type in Go matches an interface, it happens by chance.
- msbarnett 14y agoUtter nonsense. Either a function/method is semantically compatible with the expectations of its caller, or it is not. Whether or not the function/method's author typed the words "implements Foo" has absolutely no impact on this.