ios - Swift中数组如何像OC中一样取subarrayWithRange
巴扎黑
巴扎黑 2017-04-17 16:35:39
0
2
605

Swift中数组如何像OC中一样取subarrayWithRange获得子数组呢?

巴扎黑
巴扎黑

reply all(2)
小葫芦
let a = [1,2,3,4,5,6]
let b = a[2...5]
//b = [3,4,5,6]

As above

刘奇

What we get above is ArraySlice. We need to use Array to wrap it one layer

let a = [1,2,3,4,5,6]

let b = a[0...1]

//b is type of ArraySlice

let b= Array(a[0...1])
//b is array 
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template