//Swift的数组对它们能存放的值的类型是明确的。这不同于Objective-C的NSArray类和NSMutableArray类,Objective-C的数组能存储任何类型的对象
//Swift存储的数据类型要一致.
var shoplist = ["eggs","milk"]
var count = shoplist.count
print(count)
if shoplist.isEmpty{
print("the shoppinglist is empty")
}
shoplist.append("flour")//往数组末尾添加一个元素
//print(shoplist)
shoplist += ["a","b","c"]
print(shoplist)
//修改数组指定位置的值
shoplist[0] = "abc"
print(shoplist)
shoplist.insert("bb", at: 4)
shoplist.remove(at: 3)
shoplist.removeLast()
//数组的创建与初始化,重复三个55
var anotherV = Array(repeatElement("55", count: 3))
print(anotherV)
var ano = Array (arrayLiteral: 15)
print("ano == \(ano)")
//字典 字典是一种存储多个类型相同的值的容器 对字典来说,不可变还意味着你不能改变字典里某个键的值
//1.创建空字典
var dic = Dictionary<Int,String>()
//2.创建一个空的键值对。。不过没有意义.
dic = [:]
var xc = ["key":"value","key2":"value2"]
print(xc["key"])
xc["www"] = "baidu.com"
xc["www"] = "www.b"
xc.updateValue("www.baidu.com", forKey: "www")
xc["www"] = nil //也可以使用下标语法把一个键对应的值赋为nil来删除该键值对
//集合有可变 和不可变 ,,对应OC 中的NSMutable var
// NS let