1. repeat...until和break
lua
for i = 1, 5 do
repeat
if i == 3 then
break
end
print(i)
until true
end
--[[
1
2
4
5
]]
2. 使用goto
lua
for i = 1, 5 do
if i == 3 then
goto continue
end
print(i, " no continue")
::continue::
end
--[[
1 no continue
3 no continue
4 no continue
5 no continue
]]
3. 使用if...else...
lua
for i = 1, 5 do
if i ~= 3 then
print(i)
end
end
--[[
1
2
4
5
]]