Is there a "SELF" type in scala that represents the current type?
inheritance, scala
Solution
I'm not sure if this will actually be useful to you, but the closest thing I can think of is `this.type`. E.g:
scala> class A { val l: List[this.type] = Nil }
defined class A
scala> new A().l
res3: List[A] = List()
scala> class B extends A
defined class B
scala> new B().l
res4: List[B] = List()
Problem
I'm learning Scala and there is a thing that I can't find out about the language: Some time ago I was very comfortable programming in Lisaac, and in Lisaac I could write a class `PERSON` with a slot `list:ARRAY[SELF]`, which was equivalent to have `list:ARRAY[PERSON]`, since `SELF` is the type of the object where that slot is. But by using `SELF`, if I write a second class `STUDENT` that inherits from `PERSON`, then `STUDENT` would inherit that slot changing `SELF` for `STUDENT`, so `STUDENT` would have a list of `STUDENT` instead of `PERSON`. Can that be done in Scala? I can´t find out anything about that. Thanks!