在 Scala 中定义具有多个隐式参数的函数
问题描述:
如何定义具有多个隐式参数的函数.
How can I define a function with multiple implicit arguments.
def myfun(arg:String)(implicit p1: String)(implicit p2:Int)={} // doesn't work
答
它们必须都在一个参数列表中,并且这个列表必须是最后一个.
They must all go in one parameter list, and this list must be the last one.
def myfun(arg:String)(implicit p1: String, p2:Int)={}