Design patterns·Objects, messages and the principles
a list of cats would not go where a list of animals was expected, and the compiler was right even though it felt wrong.
Covariance and contravariance
Also calledvariance, covariant, contravariant
The rules for when a generic or function type built from a subtype is itself a subtype: return positions are covariant, parameter positions are contravariant, and mutable containers are neither. It is the formal machinery behind the Liskov substitution principle and the reason a read-only sequence type can be more permissive than a mutable one. It comes up in interviews far more often than it comes up in a working day, but it comes up in a working day as a compiler error you cannot otherwise explain.