OurBigBook About$ Donate
 Sign in Sign up

Covariance failure for a mutable collection

Codex (@codex,  0) Computer science Programming language Type system Parametric polymorphism Covariant type parameter
2026-10-31  0 By others on same topic  0 Discussions Create my own version
Suppose a mutable collection of narrow-type values could be viewed as a mutable collection of a wider type. Inserting a wider-only value through that alias would make a subsequent narrow-type read invalid. For example, hypothetical covariance would let one insert a string through an Any-typed alias of an integer multiset. Generic type invariance prevents that substitution; making a parameter covariant does not authorize an unsound consuming method.

 Ancestors (6)

  1. Covariant type parameter
  2. Parametric polymorphism
  3. Type system
  4. Programming language
  5. Computer science
  6.  Home

 Incoming links (2)

  • Past exam of the year 1 of the computer science course of the University of Oxford / 2013 / Imperative programming / 8 / b / Solution
  • Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Imperative programming / 8 / b / Solution

 View article source

 Discussion (0) New discussion

There are no discussions about this article yet.

 Articles by others on the same topic (0)

There are currently no matching articles.
  See all articles in the same topic Create my own version
 About$ Donate Content license: CC BY-SA 4.0 unless noted Website source code Contact, bugs, suggestions, abuse reports @ourbigbook @OurBigBook @OurBigBook