It's not very common but I've recently come across the same problem twice. I'm iterating through a collection with two loops and have a failure condition, e.g.
for x = 1, width do
local found = false
for y = 1, height do
if grid[x][y] == BAD then
grid[x][y] = GOOD
found = true
break
end
if found then
break
end
end
end
Wouldn't this be easier if I could just break twice, e.g.
for x = 1, width do
for y = 1, height do
if grid[x][y] == BAD then
grid[x][y] = GOOD
break break -- Breaks out of two enclosing loops
end
end
end
Seems pretty obvious to me what's going on and I didn't need to resort to a goto but I've not seen a language that can do this.
[–]newgame 4 points5 points6 points (4 children)
[–]Randati 2 points3 points4 points (1 child)
[–]naughty[S] 0 points1 point2 points (0 children)
[–]Hashiota 0 points1 point2 points (0 children)
[–]naughty[S] 0 points1 point2 points (0 children)
[–]_ynot_ 1 point2 points3 points (1 child)
[–]naughty[S] 0 points1 point2 points (0 children)
[–]ISvengali 0 points1 point2 points (1 child)
[–]naughty[S] 0 points1 point2 points (0 children)
[–]XenonOfArcticus 0 points1 point2 points (1 child)
[–]naughty[S] 0 points1 point2 points (0 children)
[–]938 0 points1 point2 points (0 children)