不会用代码片,求教。
创建array的方法。
var language = ["ObjectC","C++","C#","Swift" ]
读取array里的值。
language[1]
插入值
language[1] = "C"
创建dictionary
var myDictionary = [
"Beijing":"China",
"London":"England",
"Wellington":"NewZealand",
]
读取值
var nation = myDictionary["Beijing"]
插入值
myDictionary["key"] = ["value"]
创建一个空array
let emptyArray = String[]()
创建空字典
let emptyDictionary = Dictionary<String,Float>()
如果类型可以推导,array可以写成 language = []
字典可以写成 emptyDictionary = [:]