Tsallaka zuwa abun ciki
Justice Tech School

for in Loops

for in walks ranges, arrays, dictionaries and strings.

Example
for i in 1...3 { print(i, terminator: " ") }
print()
for c in "abc" { print(c, terminator: " ") }
print()
for (i, v) in ["x", "y"].enumerated() { print(i, v) }
for i in stride(from: 10, to: 0, by: -4) { print(i, terminator: " ") }
print()

Exercise

Index and value.

for (i, v) in a.()

Quiz Test

What does stride do?

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