Post

Replies

Boosts

Views

Created

Swift Playgrounds: Learn to Code 1: Roll Right Roll Left Infinitely Walking Around
Hello everyone, doing the Swift playgrounds Learn to Code 1 and am stuck on the very last one. My code walks the map and collects all gems and toggles all switches, but I am stumped on how to make him stop walking around when he's done doing all the tasks. Here's what I have: func checker() {     if isOnClosedSwitch {         toggleSwitch()     } else if isOnOpenSwitch {         moveForward()     } } while !isOnClosedSwitch {         while !isOnGem {             moveForward()             if isBlockedRight && isBlocked {                 turnLeft()                 moveForward()                 checker()                 turnLeft()                 moveForward()                 checker()             }             if isBlocked {                 turnRight()             }         } collectGem() } Any suggestions on why he won't stop walking? Obviously, I'm very new to this, so I'm trying to think using the logic I'm learning from the course and could use whatever tips on this.
1
0
755
Apr ’22