Hacker News new | past | comments | ask | show | jobs | submit login

I think that's how interfaces work. You define an interface by the methods a receiver has (a struct complying to the ReadCloser interface for example must implement Read() and Close()). While one has to get used to it, it works very nicely in practice.



I don't think so. Interfaces dispatch based on the type of the one and only special purpose receiver.


I've read this sentence 6 times and have no idea what it means...


It means that one argument to the function is special, syntactically, and it is that argument (and only that argument) that determines whether a type implements an interface.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: