def foo(x : Array[Any]) = println(x.length);
foo(Array[String]("test", "test"));
This code will raise error message:
:6: error: type mismatch;
found : Array[String]
required: Array[Any]
foo(Array[String]("test", "test"))
All classes in Scala directly or indirectly inherit from Any class. So String is Any. Why we cannot pass an Array[String] to the foo method?