I am just new to Scala and it seems a little bit confusing to me why Scala provides "curried functions" such as:
//curried function
def add(lhs: Int)(rhs: Int) = lhs + rhs
//so we can do partially binding like
val add1 = add(1)_
Its confusing because Scala already provides 'partial application' to normal functions, e.g.,
//normal function
def add(lhs: Int, rhs: Int) = lhs + rhs
//also supports partially application
val add1 = add(1, _: Int)
So my question is: is there any other point of using a curried function rather than a normal function in Scala besides partial application?
EDT1: Thanks for the replies. I think I have learned new stuff from all the answers below.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…