二元运算符“+”不能应用于“_”类型的操作数和 'String'
Binary operator '+' cannot be applied to operands of type '_' and 'String'
我是 swift 的新手。
我想使用 reduce 函数连接数组中的名称
我的代码:
let names = ["ZZZZZZ", "B", "AA", "CCCC", "EEEEE"]
let sum = names.reduce(0) {
return [=11=] +
}
我收到这个错误
二元运算符“+”不能应用于类型“_”和 'String'
的操作数
如果要reduce
字符串默认值必须是空字符串""
let sum = names.reduce("") { return [=10=] + }
实际上
let sum = names.joined()
也一样。
我是 swift 的新手。 我想使用 reduce 函数连接数组中的名称 我的代码:
let names = ["ZZZZZZ", "B", "AA", "CCCC", "EEEEE"]
let sum = names.reduce(0) {
return [=11=] +
}
我收到这个错误 二元运算符“+”不能应用于类型“_”和 'String'
的操作数如果要reduce
字符串默认值必须是空字符串""
let sum = names.reduce("") { return [=10=] + }
实际上
let sum = names.joined()
也一样。