如何在 swift 5 中的数组中添加两个字符串
How to add two strings in an array in swift 5
var oneArray = ["one","two","three","four"]
var secondArray = ["1","2","3","4"]
我想要这样的输出
oneArray = ["one 1","two 2","three 3","four 4"]
简单:
let result = zip(oneArray, secondArray).map { "\([=10=]) \()" }
参考
https://developer.apple.com/documentation/swift/zip2sequence
var oneArray = ["one","two","three","four"]
var secondArray = ["1","2","3","4"]
我想要这样的输出
oneArray = ["one 1","two 2","three 3","four 4"]
简单:
let result = zip(oneArray, secondArray).map { "\([=10=]) \()" }
参考
https://developer.apple.com/documentation/swift/zip2sequence