News for hackers. Stuff that matters.
Re:The 4-chan Go programmer by figassis on Thursday August 29, 2024 @03:28PM (#41394438)
Basically if the Jump function takes an Animal interface, the package that defines the jump function is the one that defines the Animal.Jump method. So if you provide it with whatever entity that has this method, it will just work. You don’t have to define the Animal interface in your Cat package. But if your cat does not Jump, it won’t be accepted. Of course you can also pass in a box that Jumps.

There are no comments on this comment yet.