Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a difference in Scala between Seq[T] and T*?

My IDE's tooling shows that xs has type Int* in the following snippet:

def accept(xs: Int*) = true

The language reference, however, says that a repeated parameter declared as T* has type Seq[T]. Is there a difference between Int* and Seq[Int]?

like image 728
Jean-Philippe Pellet Avatar asked Apr 12 '11 20:04

Jean-Philippe Pellet


2 Answers

They are different, and it's somewhere between bug and regrettable feature that T* leaks into type signatures.

Repeated parameter typed as T* rather than Seq[T]

like image 167
psp Avatar answered Nov 20 '22 00:11

psp


Yes, they are different. See, e.g., Overriding a repeated class parameter in Scala?

like image 2
Alexey Romanov Avatar answered Nov 20 '22 01:11

Alexey Romanov