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]
}

  

posted @ 2015-12-16 11:43  Rinpe  阅读(207)  评论(0编辑  收藏  举报