建立两个数组用于测试演示,需要注意的是first为可变数组 var first = ["张三", "李四"] let second = ["王五", "赵六"] 方法一 first.append(contentsOf: second) print(first) // ["张三", "李四", "王五", "赵六"] 方法二 first += second print(first) //["张三", "李四", "王五", "赵六"] 方法三 let third = first + sec…
建立两个数组用于测试演示,需要注意的是first为可变数组 var first = ["张三", "李四"] let second = ["王五", "赵六"] 方法一 first.append(contentsOf: second) print(first) // ["张三", "李四", "王五", "赵六"] 方法二 first += second print(first) //["张三", "李四", "王五", "赵六"] 方法三 let third = first + sec…
给定一个示例Array数组 var animals = ["cats", "dogs", "chimps", "moose"] Array删除第一个元素 animals.removeFirst() // "cats" print(animals) // ["dogs", "chimps", "moose"] Array删除最后一个元素 animals.removeLast() // "moose" print(animals) // ["cats", "dogs", "chimps"] Array删除…