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")
网友评论