Imperative Programming TT23, Type variance
Flashcards
@Define what it means for a type to be invariant.
It is neither covariant nor contravariant.
@Define what it means for a type $T$ to be covariant.
Whenever A <: B, we have T[A] <: T[B].
@Define what it means for a type $T$ to be contravariant.
Whenever A <: B, we have T[B] <: T[A].
@State the Liskov substitution principle.
If S <: T then everything you can do with a value of type T, you should also be able to do with a value of type S.