【发布时间】:2018-10-09 00:06:58
【问题描述】:
由于 Kotlin 支持函数式编程的许多概念,我想知道是否有办法在 Kotlin 中也对函数进行部分应用?
部分应用可能有用的一个例子是:
// In one class
fun doSomething(cb: (a, b) -> Unit) {
<some logic here to compute someField>
doSomethingElse(cb.applyPartially(someField))
}
// In another class
fun doSomethingElse(cb: (b) -> Unit) {
<some logic here to compute someOtherField>
cb(someOtherField)
}
【问题讨论】:
标签: kotlin functional-programming partial-application