- range可用于数组截取
let array = ["a", "b", "c", "d", "e"]
let a = array[2...3] //["c", "d"]
let b = array[2..<3] //["b"]
当然String不可以这样截取
A String substring is not Range<Int>, it's Range<String.index>
2.Floating point number don't stride by Int, they stride by a floating point value
for i stride(from: 0.5, to: 12.25, by: 0.3){
}
网友评论