4 ms·
Yeah, I kept waiting for the article to mention covariance and contravariance, and it never did. A very weird explanation of a not-that-weird phenomenon; I susp
by mkozlows 7y ago
Yeah, I kept waiting for the article to mention covariance and contravariance, and it never did. A very weird explanation of a not-that-weird phenomenon; I suspect the author didn't really understand what's going on.
- tsimionescu 7y agoTo be fair to the author of the article, the official Go blog, written by Go's designers, offers the same explanation as the article, unfortunately.
- erik_seaberg 7y agoThere was a proposal https://github.com/golang/go/issues/7512 https://github.com/golang/go/issues/7512 to make interface method return types covariant, but it didn't go anywhere, and people seemed to favor the broken behavior (returning a concrete type can fail to satisfy an interface, because the crude matching doesn't care that the type has all the expected methods).
- bogomipz 7y agoMight you or someone else have some links you could share that talk about covariance and contravariance?
- pulisse 7y agoEli Bendersky has a good post[1] on the topic. [1] https://eli.thegreenplace.net/2018/covariance-and-contravariance-in-subtyping/ https://eli.thegreenplace.net/2018/covariance-and-contravari...
- bogomipz 7y agoOh this is great read, thanks!
- js2 7y agoThe wikipedia has a good explanation: https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)#Arrays https://en.wikipedia.org/wiki/Covariance_and_contravariance_...