I've encountered this code :
ListBuffer(comp: _*)
comp is of type List[String]
What is ListBuffer(comp: _*)
achieving ? Specifically comp: _*
?
I've encountered this code :
ListBuffer(comp: _*)
comp is of type List[String]
What is ListBuffer(comp: _*)
achieving ? Specifically comp: _*
?
ListBuffer
apply method takes a vararg parameter of some type A
. In order to pass it some sequence of value, for example a List
, without explicit extraction of values you can use _*
which means: take all values from this sequence (comp
in your case) and pass them into this function as an argument.