0

在 Swift 4 中,我如何 curry func 并保留参数标签/名称:

func doSomething(a: A, b: B, c: C) {
}

let do_a = doSomething(a: value_a) // keep name a
let do_ab = do_a(b: value_b) // keep name b
let result = do_ab(c: value_c) // keep name c

来自这里的答案Curry Function in Swift

https://robots.thoughtbot.com/introduction-to-function-currying-in-swift

我可以,但是标签被省略了

let curryDo = curry(doSomething)
let doA = curryDo(value_a) // but the a label is removed here.

如何在柯里化函数中保留参数标签/名称?

4

1 回答 1

1

Swift 在版本 3 中移除了 currying 作为一个特性,并且所有当前的实现都使用了没有标记参数的闭包。

于 2018-05-23T07:26:07.893 回答