How to pass argument with star to the next method?

scala

Solution

You need to tell Scala to unpack `s`:

ListBuffer[String](s: _*)

You also don't need the the explicit types:

scala> class A (s: String*) { val l = ListBuffer(s: _*) }
defined class A

Problem

``` scala> class A (s: String*) { val l: ListBuffer[String] = ListBuffer[String](s) } <console>:8: error: type mismatch; found : String* required: String class A(s: String*) {val l: ListBuffer[String] = ListBuffer[String](s)} ``` Why is it not possible to pass the argument `s` to the apply method of ListBuffer[String] which is ``` def apply[A](elems: A*): CC[A] = { ... } ``` (Method `apply` from the `GenericCompanion.scala` ) The code `ListBuffer[String]("foo", "bar")` does work. But it seems I can not pass through the argument list of strings from `s` which is also `String*`.

Original source