Consider this code:
abstract class Foo(val s: String) {
def this(i: Int) = this("" + (i+2))
}
As far as I understand constructors aren't inherited and secondary constructors cannot be called from subclasses with super
like in Java.
Are they just a useless artifact or is there some sensible use-case for this construct?
scala> object Bar extends Foo(3)
defined module Bar
scala> Bar.s
res3: String = 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With