一、说明Swift数组中的类型必须一致,这一点与OC不同// 数组初始化var numbers = [0,1,2,3,4,5]var vowels = ["A","E","I","O","U"]// 数组的类型: [Int] 或者 Array<Int>//var numbers: [Int] = [0,1,2,3,4,5]//var numbers: Array<Int> = [0,1,2,3,4,5]// 空数组var emptyArray1:[Int] = []var emptyArray2:Array<Int> = []var emptyArray3 = [Int]()var emptyArray4 = Array<Int>()// 创建具有默认值的数组(相同元素的数组)var allZeros = Array<Int>(repeating: 0, count: 5)//[0,0,0,0,0]var allZeros2 = [Int](repeating: 0, count: 5)//[0,0,0,0,0]二、常用方法var numbers = [1,2,3,4,5]var vowels = ["A","E","I","O","U"]var emptyArray = [Int]()// 数组长度vowels.coun
...
继续阅读
(24)