For example, in C#, if Cat is a subtype of Animal, then:
IEnumerable<Cat>
is a subtype ofIEnumerable<Animal>
. The subtyping is preserved becauseIEnumerable<T>
is covariant on T.Action<Animal>
is a subtype ofAction<Cat>
. The subtyping is reversed becauseAction<T>
is contravariant on T.