数组的赋值
老师,有没有不用循环的方式将一个数组的指定几位赋值为相同的值?
我尝试这样的写法:
var array:[String]=["a","b","a","b","a","b"]
array=Array<String>(count:5,repeatedValue:"c")//没有报错,array被修改为5个c
array[2...4]=Array<String>(count: 3,repeatedValue: "d")//报错
Xcode会报错
老师,有没有不用循环的方式将一个数组的指定几位赋值为相同的值?
我尝试这样的写法:
var array:[String]=["a","b","a","b","a","b"]
array=Array<String>(count:5,repeatedValue:"c")//没有报错,array被修改为5个c
array[2...4]=Array<String>(count: 3,repeatedValue: "d")//报错
Xcode会报错
2014-12-05
举报