我学习与收藏相关的斯威夫特高阶函数降低高阶函数。我有以下与reduce
在雨燕3.0与诠释枚举
enum Coin : Int {
case Penny = 1
case Nickel = 5
case Dime = 10
case Quarter = 25
}
let coinArray: [Coin] = [.Dime, .Quarter, .Penny, .Penny, .Nickel, .Nickel]
coinArray.reduce(0,{ (x:Coin, y:Coin) -> Int in
return x.rawValue + y.rawValue
})
我收到以下错误查询:
Declared closure result Int is incompatible with contextual type _
如果你觉得一个答案回答你的问题,请考虑通过点击对号接受它! – Sweeper