//1。数组的概念和定义 var array = [,,,]
var array1:Array = [,,,]
var array2:Array<Int> = [,,,]; var array3:[Int] = [,,];
var array4:[Double] = [2.2,,]
var array5:[String] = ["a","b","c"]
println(array)
//数组可以方不同类型
var array6:[Any] = ["a",,]; //数组元素访问和在数组中插入删除
var array7 = ["a","b","c"];
array7.append("f")
array7.insert("", atIndex: )
println(array7) //var array9 = [1,2,3,4,5]
//var slice: Slice<Int> = [2,3,5]
//slice = array9[0...3]
//array9 = Array(slice)
//slice = Slice(array9)
//println(slice) //range
var range: Range<Int> = Range(start: , end: )
var range1 = ...
var range2 = ..<
println(range)
println(range1)
println(range2) //数组的批量操作
var array10 = [,,,,]
//array10[0...1] = [9,9,9,9,9]
array10.replaceRange(Range(start: , end: ), with: [,,,,])
array10 += []
array10.append()
array10 += [,,]
//array10 += slice
array10 += array10[...]
println(array10) //数组的便利 for elm in array10{
println(elm)
} for (index,value) in enumerate(array10)
{
println("index:\(index) = \(value)")
} //字典的概念和定义 var dic = [:""]
var dic2 :Dictionary<String,Int> = ["adf":]
var dic3 :Dictionary<String,String> = ["":""] println(dic) //字典的操作
var dict = ["apple":"苹果","banana":"香蕉"]
dict["apple"] = "橘子"
if let org = dict.updateValue("啦啦", forKey: "apple")
{
println(dict["apple"])
println(org)
}
//println(dict["apple"])
dict["green"] = "颜色"
println(dict) dict.removeValueForKey("apple1")
//dict.removeAll(keepCapacity: false)
println(dict)
//字典的便利 for (key,value) in dict
{
println("\(key) : \(value)")
} for key in dict.keys
{
println("\(key)")
} for key in dict.values
{
println("\(key)")
}