4
以下工作:功能特性和隱式參數
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)
^
你當然給了我一些想法,謝謝! – EECOLOR