On Wednesday, April 30, 2014 3:57:28 PM UTC+1, Stefan Karpinski wrote: > > If you ask for a Basket{Fruit} and I (covariantly) give you a > Basket{Apple}, it's fine if you only take things out of the basket – you > will always get a Fruit since Apples are Fruit. But if you try to put an > Orange, which is also a Fruit, into the basket, then there's a problem > because an Orange is not an Apple. On the other hand, if you ask for a > Basket{Fruit} and I (contravariantly) give you a Basket{Food}, it's fine if > you put things into the basket – since anything you put in will be Fruit > and all Fruit is Food (let's say), it will be ok. If you start taking > things out of the basket, expecting Fruit, however, you may get a Sausage > or a Cheese, which is not what you were expecting. >
This is a fantastic example. Thank you! You should try to get it into the wikipedia article on variance<http://en.wikipedia.org/wiki/Variance_(computer_science)> .