In following definitions, I can use {}
instead of ()
for curried functions but not for regular functions. Why?
//curried
scala> def add(i:Int)(j:Int) = {i+j}
add: (i: Int)(j: Int)Int
scala> add(1)(2)
res19: Int = 3
//{} works
scala> add(1){2}
res20: Int = 3
//{} works again
scala> add{1}{2}
res21: Int = 3
//non curried
scala> def add(i:Int,j:Int) = {i+j}
add: (i: Int, j: Int)Int
//use of {} creates error
scala> add{1,2}
<console>:1: error: ';' expected but ',' found.
add{1,2}
^