Well, I'm learning Scala so this question may be too basic for most people.
In Java I can have a static slot (function or variable) in a class, and then I will have that slot in inherited classes too.
In Scala I don't have static slots, but I have companion objects. But I'm finding out that those objects are not part of the inherited class, so if I have two classes Person
and Student
, and Person has a companion object with a variable all:List
that returns a list of all persons so I can do Person.all
, I was expecting that I could do Student.all
too, but that's not the case.
Is there any way to get the same behaviour that I would get in java?
Thanks!