【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
]]
相关推荐
水无痕simon17 小时前
1. Guava 介绍
开发语言·python·guava
AI科技星17 小时前
全域数学公理:基于32维超复数与易经卦爻的宇宙大一统理论(整理版)
c语言·开发语言·线性代数·量子计算·agi
之歆17 小时前
DAY_13JavaScript DOM 操作完全指南:实战案例、性能优化与业务价值(下)
开发语言·前端·javascript·性能优化·ecmascript
Brilliantwxx17 小时前
【C++】深度剖析 · 继承 (虚基表+虚函数表)
开发语言·c++
砍材农夫17 小时前
物联网 基于netty构建mqtt协议规范(发布/订阅模式)
java·开发语言·物联网·netty
techdashen17 小时前
Rust 泛型 vs Java 泛型:它们看起来相似,但骨子里截然不同
java·开发语言·rust
一只旭宝17 小时前
【C加加入门精讲15】:IO流缓冲区、字符串流、缓冲流及STL vector容器零基础实战教程一、博客前言
开发语言·c++
在坚持一下我可没意见17 小时前
Python 修仙修炼录 08:字典秘境,参悟键值玄机
开发语言·笔记·python·入门·字典
luck_bor17 小时前
Map&Stream流
java·开发语言
阿文的代码库17 小时前
如何在C++中使用标准库的智能指针
开发语言·c++·算法