3 ms·
> Go interfaces are explicit, not implicit, the difference is more where they are defined. That's not what the blog author wrote so what are you responding to?
by Jtsummers 2y ago
> Go interfaces are explicit, not implicit, the difference is more where they are defined.
That's not what the blog author wrote so what are you responding to? What they actually wrote:
>> If a Go struct implements the same functions as an interface, it implicitly implements the interface.
And that's correct except they use the term "functions" instead of "methods". But most people won't get confused by that distinction.
https://go.dev/tour/methods/10 https://go.dev/tour/methods/10 - "Interfaces are implemented implicitly"
- grey-area 2y agoThey are declared explicitly and implemented implicitly. Thus the analogy the author is trying to make with magic methods in more dynamic languages like python or ruby is inaccurate and IMO misleading.