scala - Compiler allows implicit varargs but there seems no way to supply them implicitly -
the following compiles:
def test(x:string)(implicit s:string *) = ??? however, there seems no way can supply implicit s.
def test2(x:string)(implicit s:string *) = test(x) // not find implicit value parameter s: string* am missing or should compiler throw exception?
this because inside method body, var-args parameters seen seq[a] instead of special type a*. can explicitly expand sequence again:
def test2(x:string)(implicit s:string*) = test(x)(s: _*) since cannot define type string*, renders implicit case useless, though:
implicit val = seq("hallo", "gallo"): _* // error: no `: _*' annotation allowed here so need use seq[string].
Comments
Post a Comment