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 關注
- 601 瀏覽
添加回答
舉報
0/150
提交
取消