Programming in Swift: Fundamentals, Episode 25: Challenge: Nested Loops & Early Exit | raywenderlich.com

Practice working with nested loops and the break and continue statements on your own, through a hands-on challenge.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/28092971-programming-in-swift-fundamentals/lessons/25

Hi!
For the example with the floor and room will it be possible to much easier to read, if you add both continue if-statements as an exclude statement in the where clause of each for-loop?
I know it will only work for continue-if-statements on every beginning of each for-loop.

floor_loop: for floor in 11...15 where floor != 13 {
    room_loop: for room in 1...4 where room != 1 {
        if floor == 12 && room == 3 {
            continue floor_loop
        }
        print("\(floor)-\(room)")
    }
}