Michael Burrows
Michael Burrows

Reputation: 331

What is wrong with this attempt to extend a Scala class that contains a vararg parameter

class U(successors:U*) {}
class V(successors:U*) extends U(successors) {}

The second line doesn't compile. Type mismatch on the second occurrence of successors.

Upvotes: 0

Views: 48

Answers (1)

Johny T Koshy
Johny T Koshy

Reputation: 3887

U* is converted to Seq[U]. Use,

class V(successors: U*) extends U(successors:_*) {}

Upvotes: 2

Related Questions