Swift:将一个数组附加至另一个数组 - Array
建立两个数组用于测试演示,需要注意的是first为可变数组
var first = ["张三", "李四"] let second = ["王五", "赵六"]
方法一
first.append(contentsOf: second) print(first) // ["张三", "李四", "王五", "赵六"]
方法二
first += second print(first) //["张三", "李四", "王五", "赵六"]
方法三
let third = first + second print(third) //["张三", "李四", "王五", "赵六"]
文章评论