2 ms·
Given an `type IBar interface { Bar() }`, if you implement all your member functions in the form `func (this \*Whatever) Bar() {...}`, then only a pointer-to-Wh
by rraawwrr 11y ago
Given an `type IBar interface { Bar() }`, if you implement all your member functions in the form `func (this \*Whatever) Bar() {...}`, then only a pointer-to-Whatever implements IBar, not values of type Whatever. However, since golang can call functions with pointer receivers on values, a member function in the form `func (this Whatever) Bar() {...}` implements IBar on both values and pointers of type Whatever.
See http://play.golang.org/p/ToRh0uK3zw http://play.golang.org/p/ToRh0uK3zw for a demonstration.
Edit:
Actually, you can call a function with a value receiver on a pointer value too, so this behavior is inconsistent =/