/**
1. The old for statement can no longer be used. For example: for (int i=0; i<4; i++)
2. New way: For i in 0..<5 = [0, 5); for i in 0...5 = [0, 5]
3. The new way of reverse for I in (0..<5). Reversed () means (5, 0];for I in (0...5). Reversed () means [5, 0]
*/
Class Viewcontroller:uiviewcontroller
{
Override Func Viewdidload ()
{
Super.viewdidload ()
Additional setup after loading the view, typically from a nib.
Demo1 ()
}
Reverse sequence traversal
Func demo1 ()
{
From 0~9
For I in 0..<10
{
Print ("i=\ (i)")
}
Print ("-------------")
Invert, from 9~0
For I in (0..<10). Reversed ()
{
Print ("i=\ (i)")
}
}
Func demo ()
{
Let list = [1, 2, 3, 4]
For NUM in list
{
Print ("num=\ (num)")
}
Countablerange<int>
Let c:countablerange<int>
Let A = 0..<5
Variable i in [0, 5) loops
For I in a
{
Print ("i=\ (i)")
}
Variable i in [0, 5] Loops
For I in 0...5
{
Print ("i=\ (i)")
}
}
}
Swift for Loop statement, note not the same as before