When we have the following basic classes
class X {
def f = println("X")
}
class Y extends X {
override def f = println("Y")
}
val a : X = Y
I think I am happy with why we get
scala> a.f
Y
But then I don't understand why we then have
scala> val b : AnyRef = new Array(10)
scala> b(0)
<console>:9: error: AnyRef does not take parameters
b(0)
since as far as I can tell AnyRef
is a superclass of Array
in a similar way to how X
was a superclass of Y
. If someone could explain this I would be very grateful.