Top posts

Every blog post that took off on Hacker News, ranked by the votes of its best submission. 3,426 posts.

Any topic
2015
1914

Covariance and Contravariance

Subtypes and supertypes are a common part of modern programming. Covariance and contravariance tell us where subtypes are accepted and where supertypes are accepted in place of the original type. This shows up frequently in most of the programming most of us do, but many developers are unaware of the concepts beyond a…