/*
* 可变数组
*/
var array:[String] = []
//增加
array.append(“1”)
//删除
array.remove(at: 0)
/*
* 不可变数组 初始化之后 只能获取不能改变
*/
let noArray = [1,2,2]
/*
* 可变字典 内容为无序
*/
var dict = [1:32, 2:2, 3:3 ]
//增加
dict[56] = 122
//替换
dict[1] = 99
//删除
dict[1] = nil
/*
* 不可变字典 初始化之后 只能获取不能改变
*/
let nodict = [1,2,2]
//: Playground - noun: a place where people can play
import UIKit
/*
* 可变数组
*/
var array:[String] = [“34”]
//增加
array.append(“1”)
//删除
array.remove(at: 0)
//两个数组拼接
let arrayTwo = [“11”,”e”]
let addArray = array + arrayTwo
//数组遍历
for temp in addArray {
print(temp)
}
for (index, temp) in addArray.enumerated() {
print("索引\(index)")
print("元素\(temp)")
}
var array = Int
array.forEach({
print($0)
})
array[0…2]
array.insert(0, at: array.startIndex)
array.removeLast()
array.removeFirst()
array.remove(at: 0)
array.removeAll()
addArray
/*
* 不可变数组 初始化之后 只能获取不能改变
*/
let noArray = [1,2,2]
/************************************/
/*
* 可变字典 内容为无序
*/
var dict = [1:32, 2:2, 3:3 ]
//增加
dict[56] = 122
//替换
dict[1] = 99
//删除
dict[1] = nil
/*
* 不可变字典 初始化之后 只能获取不能改变
*/
let nodict = [1,2,2]
let han = [1,1,1]
for model in han {
print("33")
}
var dictTwo = [6:2]
//两个字典合并
for model in dict {
let key = model.key
let value = model.value
dictTwo[key] = value
}
//字典遍历 无序
for temp in dictTwo {
print(temp)
}
for (index, temp) in dictTwo.enumerated() {
print("索引\(index)")
print("元素\(temp)")
}