Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在Swift中用数字填充数组的优雅方式_Ios_Swift - Fatal编程技术网

Ios 在Swift中用数字填充数组的优雅方式

Ios 在Swift中用数字填充数组的优雅方式,ios,swift,Ios,Swift,在Swift中有没有更优雅的方法来制作类似的东西 var indexArray: [Int] = [] for i in -14...14 { indexArray.append(i) } 是的: 是的: 试试看 var arr: [Int] = Array(-14...14) 试试看 var arr: [Int] = Array(-14...14)

在Swift中有没有更优雅的方法来制作类似的东西

var indexArray: [Int] = []
for i in -14...14 {
    indexArray.append(i)
}
是的:

是的:

试试看

var arr: [Int] = Array(-14...14)
试试看

var arr: [Int] = Array(-14...14)