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 it is not possible to pass an argument sto the apply ListBuffer [String] method, which is
def apply[A](elems: A*): CC[A] = { ... }
(Method applyof GenericCompanion.scala)
The code is ListBuffer[String]("foo", "bar")working. But it looks like I can't go through the list of string arguments from s, which is also String*.
source
share