Programming in Swift: Fundamentals

Oct 19 2021 · Swift 5.5, iOS 15, Xcode 13

Part 3: Control Flow

22. Iterating Collections

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 21. Challenge: For Loops Next episode: 23. Challenge: Iterating Collections

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 22. Iterating Collections

Update Notes: The student materials have been reviewed and are updated as of October 2021.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

Now, you’ve probably figured out that loops must be useful for more things than just counting up from zero to nine, or printing strings a certain number of times.

for i in 0...
for i in 0...daysOfTheWeek.count {
    
}
for i in 0...daysOfTheWeek.count {
  print("\daysOfTheWeek[i]: \poolTemperature[i]")
}
for i in 0..<daysOfTheWeek.count {
  print("\(daysOfTheWeek[i]): \(poolTemperature[i])")
}
for i in 0..<daysOfTheWeek.count where poolTemperature[i] >= 80 {
  print("\(daysOfTheWeek[i]): \(poolTemperature[i])")
}
var sum = 0
for temperature in poolTemperature {
}
for temperature in poolTemperature {
    sum += temperature
}
sum / poolTemperature.count