Programming in Swift: Fundamentals

Oct 19 2021 Swift 5.5, iOS 15, Xcode 13

Part 3: Control Flow

20. For Loops

Lesson Complete

Play Next Lesson
Next
Save for later
About this episode
See versions

See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 19. Challenge: While Loops Next episode: 21. Challenge: For Loops

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.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

So far, you’ve learned how to control the flow of execution in your apps using the decision-making powers of if statements and the while loop.

let closedRange = 0...5
let halfOpenRange = 0..<5
var usefulValue = 5
let closedRange = 0...usefulValue
let halfOpenRange = 0..<usefulValue

var sum = 0
let count = 10
for i in 1...count {
  
}
  sum += i 
i = 20
for _ in 1...count {
  print("roar")
}
for _ in 1...count where count > 100 {
  print("roar")
}
for i in 1...count { 

}
for i in 1...count {
   print("\(i) is an odd number.")
}
5 % 2
for i in 1...count where i % 2 == 1 {