Top "Contravariance" questions

Within the type system of a programming language, covariance and contravariance refers to the ordering of types from narrower to wider and their interchangeability or equivalence in certain situations (such as parameters, generics, and return types)

How is Generic Covariance & Contra-variance Implemented in C# 4.0?

I didn't attend PDC 2008, but I heard some news that C# 4.0 is announced to support Generic covariance and contra-variance. That …

c# c#-4.0 covariance contravariance generic-variance
Generics : List<? extends Animal> is same as List<Animal>?

I am just trying to understand the extends keyword in Java Generics. List<? extends Animal> means we can …

java generics covariance extends contravariance
Covariance, Invariance and Contravariance explained in plain English?

Today, I read some articles about Covariance, Contravariance (and Invariance) in Java. I read the English and German Wikipedia article, …

java covariance contravariance
Why doesn't the example compile, aka how does (co-, contra-, and in-) variance work?

Following on from this question, can someone explain the following in Scala: class Slot[+T] (var some: T) { // DOES NOT …

generics scala covariance contravariance
Difference between Covariance & Contra-variance

I am having trouble understanding the difference between covariance and contravariance.

c# c#-4.0 covariance contravariance
Understanding Covariant and Contravariant interfaces in C#

I've come across these in a textbook I am reading on C#, but I am having difficulty understanding them, probably …

c# .net interface covariance contravariance
Contravariance explained

First of, I have read many explanations on SO and blogs about covariance and contravariance and a big thanks goes …

c# c#-4.0 covariance contravariance
Casting from IEnumerable<Object> to IEnumerable<string>

Recently I found a very surprising behavior in c#. I had a method which takes IEnumerable<Object> as …

c# covariance contravariance
Generic wildcards in variable declarations in Scala

In Java I might do this: class MyClass { private List<? extends MyInterface> list; public void setList(List<…

java generics scala covariance contravariance