Tsallaka zuwa abun ciki
Justice Tech School

Swift Loops

for in loops over ranges and collections. while and repeat while repeat on a condition. break and continue control the flow.

Example
for i in 1...3 { print("i=\(i)") }
var n = 3
while n > 0 { n -= 1 }
repeat { n += 1 } while n < 3
print(n)

Exercise

Run at least once.

 { } while x

Quiz Test

Which loop always runs once?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.