swift 闭包中怎么调用方法
2 回答
拉风的咖菲猫
TA贡献1995条经验 获得超2个赞
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 关注
- 561 浏览
添加回答
举报
0/150
提交
取消