|
|
Re: Calling super class constructor
|
Posted: Dec 24, 2007 4:19 PM
|
|
> I need to be more precise, I wish to define a Scala > subclass with a no-argument constructor that extends a > Java class with a parameterized constructor, so I need to > call "'super" and set some parameter values. > > Randy
It's done the same way if the superclass is Scala. Here's an example:
scala> class Fred(x: Int, y: Int) {} defined class Fred
scala> class Bob extends Fred(1, 2) {} defined class Bob
After extends you say the name of the superclass. Just put the parameters in parens after that name.
|
|