swift 中的数组
· Array 数组
· 使用 [ ] 操作符声明数组
//数组
let myArray1 = [] //声明空数组
//let myArray2 = String[]() //这种方式会出现以下异常
//instance member 'subscript' cannot be used on type 'String'
var shoppingList = ["mac","ipad","iphone"] //声明数组
//数组中的常用方法
print(shoppingList.count) //数组的个数
print(shoppingList.capacity) //数组的容量(容量的值>=count,并且是2的次方)
print(shoppingList.isEmpty) //数组是否为空
//增加
shoppingList.append("ipod") //给数组增加一个元素
print(shoppingList) //输出这个数组的元素
shoppingList.insert("iMac", atIndex:2)