码迷,mamicode.com
首页 > 其他好文 > 详细

Swift_2_控制语句

时间:2014-07-21 13:23:47      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:swift

import Foundation

println("Hello, World!")

/*
for  do While  While Switch
*/

var arr = [1,2,3,4,5,7];

for i in arr{
    println(" i is \(i)");
}

var count = arr.count;

for (var i = 0 ; i<count; i++){
    var index = arr[i];
    println("index is \(index)");
}

var index = 0;

do{
    var j = arr[index];
    println("j is \(j)");
}while(++index < count);


var x = 0;
while(x<count){
    println("arr num is \(arr[x]) index = \(x++)");
};

var type = "iOS"

///没有break默认不执行下面语句, 如果想要执行(穿透)就加上fallthrough
switch type{
    case "iOS":
        println("------")
//        fallthrough;
    case "22":
        println("=======")
    default:
        println("三三三三三")
}


Swift_2_控制语句

标签:swift

原文地址:http://blog.csdn.net/yin_xianwei/article/details/38013949

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