scala柯里化函数

定义curried函数:def add(a: Int)(b: Int)=a+b

调用:                    var addOne=add(1) _

                                addOne(2)

out:                             3


将已有函数curried(科里化)

被curried函数:def add(a: Int, b: Int): Int=a+b

curried:             val addCurried= (add _).curried

    调用:            val addOne=addCurried(1)

                           addOne(2)

    out:                 3


你可能感兴趣的:(scala柯里化函数)