swift.reversed()有相同的效果
代码演示
var dataSource : [Int] = [0,1,2,3,4,5,6,7,8,9]
func exchange(dataSource : [Int]) -> [Int]{
var data = dataSource
let count = dataSource.count
for i in 0 ..< count / 2{
let t = data[i]
data[i] = data[count - i - 1]
data[count - i - 1] = t
}
return data
}
网友评论