Reputation: 1526
In the example on this page: http://www.scala-lang.org/node/125
class Point(xc: Int, yc: Int) {
val x: Int = xc
val y: Int = yc
def move(dx: Int, dy: Int): Point =
new Point(x + dx, y + dy)
}
class ColorPoint(u: Int, v: Int, c: String) extends Point(u, v) {
val color: String = c
def compareWith(pt: ColorPoint): Boolean =
(pt.x == x) && (pt.y == y) && (pt.color == color)
override def move(dx: Int, dy: Int): ColorPoint =
new ColorPoint(x + dy, y + dy, color)
}
What purpose does the argument/parameter list on the extended class serve in the definition of the subclass? I am referring to the (u, v)
on the end of Point
in the line class ColorPoint(u: Int, v: Int, c: String) extends Point(u, v) {
.
Upvotes: 0
Views: 353
Reputation: 62855
If you familiar with Java this code would be identical:
class ColorPoint extends Point {
ColorPoint (int u, int v, String c) {
super(u,v);
...
}
...
}
So, yes, it is call to super's constructor
Upvotes: 3