Reputation: 11244
The following compiles:
def test(x:String)(implicit s:String *) = ???
However, there seems no way I can supply the implicit s
.
def test2(x:String)(implicit s:String *) =
test(x) // could not find implicit value for parameter s: String*
Am I missing something or should the compiler throw an exception?
Upvotes: 1
Views: 104
Reputation: 67290
This is because inside the method body, the var-args parameters are seen as Seq[A]
instead of the special type A*
. You can explicitly expand the sequence again:
def test2(x:String)(implicit s:String*) = test(x)(s: _*)
Since you cannot define a type as String*
, it renders the implicit case useless, though:
implicit val a = Seq("hallo", "gallo"): _*
// error: no `: _*' annotation allowed here
So you will need to use Seq[String]
.
Upvotes: 1