可能重複:
What's the rationale behind curried functions in Scala?斯卡拉:兩種方法之間的差異聲明函數
我有兩個區別的方式來聲明函數:1)使用鑽營。 2)使用功能作爲參數。
這裏是我的代碼:
def transform(f: Double => Double)(input: Double) = {
f(input)
}
def transformVer2(f: Double => Double, input: Double) = {
f(input)
}
transform(x=>x*x)(10) //> res8: Double = 100.0
transformVer2(x=>x*x, 10) //> res9: Double = 100.0
我不知道是什麼的上面兩個函數的聲明,真正的差別。請告訴我。
謝謝:)
不,我不這麼認爲。在我的問題中,參數是一個函數:) – hqt
它沒有任何區別,它仍然是一個問題。 –