【Lua】lua实现C# continue效果

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
]]
相关推荐
jinanwuhuaguo2 分钟前
OpenClaw 2026年4月升级大系深度解读剖析:从“架构重塑”到“信任内建”的范式跃迁
android·开发语言·人工智能·架构·kotlin·openclaw
geovindu13 分钟前
go: Simple Factory Pattern
开发语言·后端·设计模式·golang·简单工厂模式
xixixi7777723 分钟前
从5G标准到6G前沿:Polar码的技术演进与未来之路
开发语言·人工智能·5g·大模型·php·通信·polar码
小二李31 分钟前
什么是依赖注入(DI)&控制反转IoC
java·开发语言
是宇写的啊41 分钟前
SpringIoc和Di
java·开发语言
沐雪轻挽萤42 分钟前
3. C++17新特性-带初始化的 if 和 switch 语句
开发语言·c++
xianluohuanxiang1 小时前
2026年深度:高精度气象+新能源,从风速误差到收益偏差,行业赋能正在重构电站盈利模型
大数据·开发语言·人工智能·机器学习
froginwe111 小时前
SQL PRIMARY KEY(主键)
开发语言
2401_885885041 小时前
视频短信接口集成起来复杂吗?API接入说明
开发语言·php·音视频
Thexhy1 小时前
Java 后端完整成长路线(含项目)
java·开发语言