Iterating Collections with for-in
Looping over arrays, dictionaries and sets with enumerated and zip.
Welcome
The `for-in` loop works with any `Sequence` — arrays, dictionaries, sets, strings, and your own custom types. Let's see the most useful patterns.
Iterating an Array
```swift
let fruits = ["apple", "banana", "cherry"]
for fruit in fruits {
print(fruit)
}
// apple, banana, cherry
```
Each element is bound to `fruit` for one iteration.
All lessons in this course
- for-in Loops with Ranges
- while and repeat-while Loops
- Iterating Collections with for-in
- break, continue and Labeled Statements