我正在浏览 this来自 Mikeash 的博客并找到以下声明:
private let f: AnyObject -> Parameters -> Void
我不清楚这个语法是什么意思。我尝试查看 Swift 编程指南,但没有找到任何答案。
有人可以解释一下吗,可能是一些引用?
最佳答案
参见 Swift Programming Language Reference ,章节类型,标题函数类型:
The function types of a curried function are grouped from right to left. For instance, the function type
Int -> Int -> Int
is understood asInt -> (Int -> Int)
— that is, a function that takes an Int and returns another function that takes and return an Int. Curried function are described in Curried Functions.
(我格式化了代码部分)
参见 here有关柯里化(Currying)函数的解释。
关于swift - 未知的 Swift 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28493113/