contravariance

Etymology

contra- + variance

noun

  1. (object-oriented programming) The reversal of the order of data types acted upon by an operator.
    Coordinate term: covariance
    I get why with covariance I can return a Dog (a Dog is a Mammal), but why does contravariance work the other way? Shouldn't it accept a derived type when it expects a base type? Contravariance is consistent with Postel's Law: […] 2005, Jesse Liberty, Visual C# 2005: A Developer's Notebook, O'Reilly Media, page 47
  2. (category theory) A functor which reverses composition.
  3. (linear algebra) Of vectors, the property of scaling inversely with a change of basis, as opposed to covariance.

Attribution / Disclaimer All definitions come directly from Wiktionary using the Wiktextract library. We do not edit or curate the definitions for any words, if you feel the definition listed is incorrect or offensive please suggest modifications directly to the source (wiktionary/contravariance), any changes made to the source will update on this page periodically.