Scala inherit parameterized constructor

Viewed 19423

I have an abstract base class with several optional parameters:

abstract case class Hypothesis(
    requirement: Boolean = false,
    onlyDays:   Seq[Int] = Nil,
    …
) extends Something {…}

Do i really need to explicitly repeat all parameters with the additional keywords override val on top

case class SomeHypothesis(
    anotherArg: SomeType,
    override val requirement: Boolean = false,
    override val onlyDays:   Seq[Int] = Nil,
    …
) extends Hypothesis(
    requirement,
    onlyDays,
    …
) {…}

Or is there a syntax like

case class SomeHypothesis(anotherArg: SomeType, **) extends Hypothesis(**) {…}

I don’t even need anotherArg, just a way to pass all keyword args to the super constructor.


I really like Scala’s idea about constructors, but if there isn’t a syntax for that one, I’ll be disappoint :(

4 Answers
Related