How does the Scala toSeq: _ * syntax work?

In Scala Code

val s = Set(List(1,2,3).toSeq:_*)

how does the syntax work toSeq:_*? I know what the code does, I know what it does toSeq, I understand List(1,2,3).toSeq:Seq[Int]. Is this a toSeq:_*special case?

+4
source share
1 answer

toSeqdoes nothing here and should be omitted. The following is equivalent:

Set(List(1, 2, 3): _*)

(Or even better, just write List(1, 2, 3).toSet.)

, , , , _*, ( , . 4.6.2 ). Seq, List, toSeq - .

+2

Source: https://habr.com/ru/post/1542175/


All Articles