Friday, June 15, 2012

Those parentheses in inline anonymous function application in Scala


scala> (x:Int,y:Int)=>x+y
res26: (Int, Int) => Int =

scala> res26(_:Int,10)
res27: Int => Int =

scala> res27(1)
res28: Int = 11

scala> res26(_:Int,10)(1)
:9: error: Int does not take parameters
              res26(_:Int,10)(1)
                             ^

scala> (res26(_:Int,10))(1)
res30: Int = 11


No comments: