首页 > 编程语言 > 详细

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

时间:2015-12-16 12:21:30      阅读:120      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!