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

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -