【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
]]
相关推荐
电饭叔7 分钟前
文本为 “ok”、前景色为白色、背景色为红色,且点击后触发 processOK 回调函数的 tkinter 按钮
开发语言·python
Never_Satisfied1 小时前
在c#中,string.replace会替换所有满足条件的子字符串,如何只替换一次
开发语言·c#
Demon_Hao3 小时前
JAVA快速对接三方支付通道标准模版
java·开发语言
xyq20243 小时前
C# 判断语句详解与应用
开发语言
野犬寒鸦3 小时前
深入解析HashMap核心机制(底层数据结构及扩容机制详解剖析)
java·服务器·开发语言·数据库·后端·面试
##学无止境##4 小时前
从0到1吃透Java负载均衡:原理与算法大揭秘
java·开发语言·负载均衡
Desirediscipline5 小时前
#define _CRT_SECURE_NO_WARNINGS 1
开发语言·数据结构·c++·算法·c#·github·visual studio
知识即是力量ol5 小时前
多线程并发篇(八股)
java·开发语言·八股·多线程并发
尘缘浮梦5 小时前
协程asyncio入门案例 1
开发语言·python