- 申明一个空数组要指定数组类型
var emptyArray = [String]()
- 合并数组
var list = ["one","two","three"]
var listTemp = ["zero"]
var resultArray = list + listTemp
print(resultArray) // ["one", "two", "three", "zero"]
- 添加元素
var list = ["one","two","three"]
list.append("four")
print(list) // ["one", "two", "three", "four"]
- 数组置空
list = []
- 插入元素
var list = ["one","two","three"]
list.insert("zero", at: 0)
print(list) // ["zero", "one", "two", "three"]
网友评论