Being new to Scala (2.9.1), I have a List[Event]
and would like to copy it into a Queue[Event]
, but the following Syntax yields a Queue[List[Event]]
instead:
val eventQueue = Queue(events)
For some reason, the following works:
val eventQueue = Queue(events : _*)
But I would like to understand what it does, and why it works? I already looked at the signature of the Queue.apply
function:
def apply[A](elems: A*)
And I understand why the first attempt doesn't work, but what's the meaning of the second one? What is :
, and _*
in this case, and why doesn't the apply
function just take an Iterable[A]
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…