Programming in Swift: Fundamentals

Oct 19 2021 Swift 5.5, iOS 15, Xcode 13

Part 3: Control Flow

24. Nested Loops & Early Exit

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: 23. Challenge: Iterating Collections Next episode: 25. Challenge: Nested Loops & Early Exit

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 in this course, you’ve been working with loops that operate over full ranges; in other words, your loop always goes from start to finish with no interruption.

for i in 0..<daysOfTheWeek.count {
    print("\(daysOfTheWeek[i]): \(poolTemperature[i])")
}
    if daysOfTheWeek[i] == "Thursday" {

    }
    if daysOfTheWeek[i] == "Thursday" {
        break
    }
for i in 0..<daysOfTheWeek.count {
    if daysOfTheWeek[i] == "Thursday" {
        break
    }
    print("\(daysOfTheWeek[i]): \(poolTemperature[i])")
}
    if daysOfTheWeek[i] == "Friday" {
        print("I'm in love")
        continue
print("---")
for floor in 11...15 {
    print(floor)
}
for floor in 11...15 {
    for room in 1...4 {

    }
}
        print("\(floor)-\(room)")
        if room == 1 {
            continue
        }
    if floor == 13 {

    }
    if floor == 13 {
        continue
    }
        if floor == 12 && room == 3 {
            continue
        }
floor_loop: for floor in 11...15 {
    if floor == 13 {
        continue
    }
    room_loop: for room in 1...4 {
        if floor == 12 && room == 3 {
            continue floor_loop
        }