zizouraj
zizouraj

Reputation: 493

Why are Covariance and Contravariance named like that?

I was wondering why the terms Covariance and Contravariance are named like that in programming domain. Usually one hears these terms in Probability theory or Statistics indicating the spread of quantities being measured with respect to the Mean.

I know that Covariance is the ability to assign an expression of a more specific type to a variable of a less specific type but, is there another interpretation for this?
Examples relating both these domains would be helpful.

Upvotes: 6

Views: 174

Answers (1)

alaendle
alaendle

Reputation: 21

I'm not a mathematician, so I wouldn't try to answer the question my own, but you can find a wonderful explanation to your question on Tomas Petricek's blog.

He explains in detail there how covariance and contravariance in programming are related to pure mathematical category theory.

Upvotes: 2

Related Questions