I noticed that I can extend the class and at the same time pass parameters to the extended class:
scala> class SomeClass(val str: String) defined class SomeClass scala> class SubclassOne extends SomeClass("one") defined class SubclassOne scala> class SubclassTwo extends SomeClass("two") defined class SubclassTwo scala> val obj : SomeClass = new SubclassOne obj: SomeClass = SubclassOne@2dca4eb4 scala> obj.str res0: String = one
I work a lot with case classes, where ClassName(args) actually creates an object, so it seems to me that I am expanding the object, but I'm not sure here.
Perhaps this means that I am extending the class and automatically pass the argument to the super constructor?
source share