Swift - 12 - 区间运算符和for-in
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
var a = 1, b = 10
// a到b(包含a,b) [a,b]
a...b
// a到b-1(包含a,不包含b) [a,b)
a..<b
// for-in循环
for index in a..<b { // index为常量
index
}
var array = ["Rinpe", "Bobo", "Lala"]
for index in 0...(array.count - 1) {
array[index]
}

浙公网安备 33010602011771号