I understand the terms co-variance and contra-variance. But there is one small thing I am unable to understand. In the course "Functional Programming in Scala" on coursera, Martin Ordersky mentions that:
Functions are contravariant in their argument types and co-variant in their return types
So for example in Java, let Dog
extends Animal
. And let a function be :
void getSomething(Animal a){
and I have the function call as
Dog d = new Dog();
getSomething(d)
So basically what is happeneing is that Animal a = d
. And according to wiki covariance is "Converting wider to narrow". And above we are converting from dog to Animal. SO isnt the argument type covariant rather than contravariant?