Group Group Group Group Group Group Group Group Group

Programming in Swift: Fundamentals · Nested Loops and Early Exit | raywenderlich.com


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

in the section nested loops and early exits, u wrote a code that checks for strict equality
if floor == 12 and room == 3 but somehow it hides floor == 12 and room ==4, though u added the loop_label but i still don’t get it

Hey @ugozeal:

So when the code hits the point where floor == 12 && room == 3, the continue floor_loop line sends the execution back to the outside floor_loop … which immediately increments the loop counter to 13, since it was at 12, and continues through the loop (which ends pretty quickly, with that check for floor == 13.

I’ve diagrammed this a little, let me know if it helps:

image