以下作品:
object X extends (Int => String => Long) {
def apply(x:Int):String => Long = ???
}
我怎样才能输入一个apply
带implicit
参数的函数?
我有以下方法:
def apply(x:Int)(implicit y:String):Long = ???
如何描述函数类型?
object X extends <functionType> {
def apply(x:Int)(implicit y:String):Long = ???
}
更新
我可以这样定义:
object X extends (Int => String => Long) {
def apply(x:Int):(String => Long) = ???
def apply(x:Int)(implicit y:String):Long = ???;
}
但随后调用它不起作用:
error: ambiguous reference to overloaded definition,
both method apply in object X of type (x: Int)(implicit y: String)Long
and method apply in object X of type (x: Int)String => Long
match argument types (Int)
X(3)
^