Covariance and contravariance (computer science): Difference between revisions

Content deleted Content added
Giving an example of a language that supports contravariance in parameter types
RnTkm (talk | contribs)
Formal definition: {{More citations needed section}}
Line 13:
 
== Formal definition ==
{{More citations needed section|date=November 2021}}
Within the [[type system]] of a [[programming language]], a typing rule or a type constructor is:
* ''covariant'' if it preserves the [[subtyping|ordering of types (≤)]], which orders types from more specific to more generic: If <code>A ≤ B</code>, then <code>I<nowiki><A> ≤ I<B></nowiki></code>;