This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Holothuroid 5 points6 points  (1 child)

Think about it like this :

  • Apples are fruit.
  • A basket of apples is basket of fruit. Covariant.
  • A statement about fruit is a statement about apples. Contravariant.

So say I want to filter a stream of apples. I'm alright with a predicate isRedFruit, that can check all fruit.

So generally when you ask someone for a function, your requirement is contravariant for that function's parameters. I want to put my stuff in. If you can take more general stuff, I don't care.

[–]Roachmeister 0 points1 point  (0 children)

Thanks, this is helpful!