美文网首页
2018-10-11循环语句

2018-10-11循环语句

作者: 赵饿魔 | 来源:发表于2019-05-20 09:45 被阅读0次

import UIKit

var str = "Hello, playground"

//item每次遍历的那个索引对应的值,自动赋值

//items遍历的那个集合

foritemin[1,2,3,4]

{

    print(item)

}

forindexin0..<10

{

    print(index)

}

for _ in 0..<3 //当某个值用不到的时候 用_代替

 {

    print("Hello")

}//for  _ in 0..<10

//{

  //  print("Hello World")

//}

for _ in 0..<10

{

    ifindex==5

    {

        break//跳出循环,循环体不在执行

    }

    print("World")

}

//_ = callFun

//var a = 10

//while a == 10

//{

  //  print("A")

    //a = a + 1

//}

forindexin0...5

{

    ifindex ==2

    {

        continue//跳出本次循环,后面的循环依然可以循环

    }

    print("\(index) -- Welcome")

相关文章

网友评论

      本文标题:2018-10-11循环语句

      本文链接:https://www.haomeiwen.com/subject/xynvaftx.html