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
I don't know if this is what you meant, but a companion object can extend from some traits/classes:
class Person
class Student extends Person
trait Aggregation[T] {
val all: List[T]
}
object Person extends Aggregation[Person] {
val all: List[Person] = List(new Person, new Person)
}
object Student extends Aggregation[Student] {
val all: List[Student] = List(new Student, new Student)
}
println(Person.all) // prints all persons
println(Student.all) // prints all students