Programming in Swift: Fundamentals

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

Part 3: Control Flow

18. While Loops

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: 17. Introduction Next episode: 19. Challenge: While Loops

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: 18. While Loops

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

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

What if you had to write some Swift code to print out a string 100 times? It would be tedious to write 100 print statements, but it would also violate the “Don’t Repeat Yourself” rule 99 times.

var i = 1
while i < 10
while i < 10 {

}
while i < 10 {
  print(i)
}
while i < 10 {
  print(i)
  i += 1
}
print("Counting up again")
i = 1
repeat {

}
repeat {
  print(i)
  i += 1
} 
var i = 10

i = 10