注意:對於更一般問題的詳細答案在Stack Overflow問題What are the precise rules for when you can omit parenthesis, dots, braces, = (functions), etc.?。具有咖喱功能的Scala無點呼叫語法
以下工作:
scala> List(1,2,3) filter (_ > 1) reduceLeft(_ + _)
res65: Int = 5
而且還有如下:
scala> List(1,2,3).filter(_ > 1).foldLeft(0)(_ + _)
res67: Int = 5
而不是現在這樣的語法時才:
scala> List(1,2,3) filter (_ > 1) foldLeft(0)(_ + _)
<console>:10: error: 0 of type Int(0) does not take parameters
List(1,2,3) filter (_ > 1) foldLeft(0)(_ + _)
^
什麼是修復建議?
Marimuthu,你應該加入你的答案。 – mkneissl 2010-10-27 12:50:44