Scala: Passing one implicit parameter implicitly and the other explicitly. Is it possible?
问题 Let's consider the function: def foo(implicit a:Int, b:String) = println(a,b) . Now, let us assume that there is an implicit String and Int ( implicit val i1=1 ) in scope but we want to pass an other, not implicit Int ( val i2=2 ) explicitly to foo . How can we do that ? Is it possible? Thanks for reading. 回答1: All I can add is: def foo(implicit a: Int, b: String) = println(a, b) implicit val i1 = 1 implicit val s = "" val i2 = 2 foo(i2, implicitly[String]) 回答2: In case your method has many