【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
]]
相关推荐
leaves falling18 小时前
C++模板进阶
开发语言·c++
坐吃山猪18 小时前
Python27_协程游戏理解
开发语言·python·游戏
gCode Teacher 格码致知18 小时前
Javascript提高:小数精度和随机数-由Deepseek产生
开发语言·javascript·ecmascript
椰猫子19 小时前
Javaweb(Filter、Listener、AJAX、JSON)
java·开发语言
盛世宏博北京19 小时前
以太网温湿度传感器运维技巧,提升设备稳定性与使用寿命
开发语言·php·以太网温湿度传感器
代码改善世界19 小时前
【MATLAB初阶】矩阵操作(一)
开发语言·matlab·矩阵
覆东流19 小时前
第1天:Python环境搭建 & 第一个程序
开发语言·后端·python
朝阳58120 小时前
rust 交叉编译指南
开发语言·后端·rust
量子炒饭大师21 小时前
【C++ 进阶】Cyber霓虹掩体下的代码拟态——【面向对象编程 之 多态】一文带你搞懂C++面向对象编程中的三要素之一————多态!
开发语言·c++·多态
xiaoshuaishuai821 小时前
C# 实现百度搜索算法逆向
开发语言·windows·c#·dubbo