自学内容网 自学内容网

【Lua】lua实现C# continue效果

1. repeat…until和break

for i = 1, 5 do
repeat
if i == 3 then
break
end
print(i)
until true
end

--[[
1
2
4
5
]]

2. 使用goto

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…

for i = 1, 5 do
if i ~= 3 then
print(i)
end
end

--[[
1
2
4
5
]]

原文地址:https://blog.csdn.net/weixin_44293426/article/details/140348068

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!