swift 閉包中怎么調(diào)用方法
2 回答

qq_笑_17
TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超7個(gè)贊
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 關(guān)注
- 1434 瀏覽
添加回答
舉報(bào)
0/150
提交
取消