码迷,mamicode.com
首页 > 编程语言 > 详细

Swift - 12 - 区间运算符和for-in

时间:2015-12-16 12:21:53      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

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

  

Swift - 12 - 区间运算符和for-in

标签:

原文地址:http://www.cnblogs.com/Rinpe/p/5050658.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!