问题
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]
?
回答1:
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]
回答2:
Yes, they are different. See, e.g., Overriding a repeated class parameter in Scala?
来源:https://stackoverflow.com/questions/5641543/is-there-a-difference-in-scala-between-seqt-and-t