swift 闭包中怎么调用方法
2 回答
qq_笑_17
TA贡献1818条经验 获得超7个赞
1 2 3 4 5 6 7 8 | func calc(x: Int, y: Int, callback: @escaping (Int, Int) -> Int) -> Int { return callback(x, y) }
let add = calc(x: 1, y: 2) { return $0 + $1 } let reduce = calc(x: 4, y: 3) { x, y in return x - y }
print(add, reduce) |
- 2 回答
- 0 关注
- 1388 浏览
添加回答
举报
0/150
提交
取消