1
鑑於Scala的類型推斷,我期望下不失敗:爲什麼scala不能推斷部分應用函數中的類型?
scala> def partiallyApplied(x: Int, y: Int, z: Int) = x + y + z
partiallyApplied: (x: Int, y: Int, z: Int)Int
scala> val partialSum = partiallyApplied(2, 3, _)
<console>:11: error: missing parameter type for expanded function ((x$1) => partiallyApplied(2, 3, x$1))
val partialSum = partiallyApplied(2, 3, _)
^
,當然還有,這個工程:
scala> val partialSum = partiallyApplied(2, 3, _:Int)
partialSum: Int => Int = <function1>
是否有一個原因,類型推斷不符合部分應用幫助在這種情況下的功能?