美文网首页
Range(swift) 截取数组

Range(swift) 截取数组

作者: Just_go | 来源:发表于2017-06-28 14:34 被阅读1321次
  1. 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){
}

相关文章

网友评论

      本文标题:Range(swift) 截取数组

      本文链接:https://www.haomeiwen.com/subject/ygzycxtx.html