I've solved it without using a switch as a condition of While :D
while !isBlocked || !isBlockedLeft && !isBlockedRight {
moveForward()
if isBlocked && isOnGem{
turnRight()
} else if isBlockedRight && isBlocked{
turnLeft()
} else if isOnClosedSwitch && isBlocked{
turnLeft()
} else if isBlockedLeft && isBlocked{
turnRight()
}
if isOnGem{
collectGem()
} else if isOnClosedSwitch{
toggleSwitch()
}
}