Programming in Swift: Fundamentals

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

Part 3: Control Flow

24. Nested Loops & Early Exit

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

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: 24. 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.

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
        }