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

落爺英雄遲暮 提交于 2020-01-24 03:01:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!