我正在浏览Apple对Swift的介绍,并遇到了这样的例子:
func makeIncrementer() -> ((Int) -> Int) {
func addOne(number: Int) -> Int {
return 1 + number
}
return addOne
}
var increment = makeIncrementer()
increment(7)
Run Code Online (Sandbox Code Playgroud)
你能解释一下makeIncrementer函数的返回类型的语法吗?我理解这个函数返回另一个函数,但((Int) -> Int)在这个上下文中的作用对我来说仍然不清楚.
| 归档时间: |
|
| 查看次数: |
1270 次 |
| 最近记录: |