标签: swift
如果有两个这样迅速创建的数组:
var a:[String] = ["1", "2", "3"] var b:[String] = ["A","B","C"]
如何将它们合并到[“ 1-A”,“ 2-B”,“ 3-C”]?
答案 0 :(得分:2)
您可以尝试
let a = [1, 2, 3] let b = ["A","B","C"] let res = zip(a, b).map { "\($0)-\($1)" } print(res)