Lua repeat...until 循环
Lua 教程
· 2019-02-27 17:42:19
Lua 编程语言中 repeat...until 循环语句不同于 for 和 while循环,for 和 while 循环的条件语句在当前循环执行开始时判断,而 repeat...until 循环的条件语句在当前循环结束后判断。
语法
Lua 编程语言中 repeat...until 循环语法格式:
repeat statements until( condition )
我们注意到循环条件判断语句(condition)在循环体末尾部分,所以在条件进行判断前循环体都会执行一次。
如果条件判断语句(condition)为 false,循环会重新开始执行,直到条件判断语句(condition)为 true 才会停止执行。Lua repeat...until 循环流程图如下:
实例
--[ 变量定义 --]
a = 10
--[ 执行循环 --]
repeat
print("a的值为:", a)
a = a + 1
until( a > 15 )
执行以上代码,程序输出结果为:
a的值为: 10 a的值为: 11 a的值为: 12 a的值为: 13 a的值为: 14 a的值为: 15
点击查看所有 Lua 教程 文章: https://www.codercto.com/courses/l/21.html
Head First Mobile Web
Lyza Danger Gardner、Jason Grigsby / O'Reilly Media / 2011-12 / $ 50.84
Despite the huge number of mobile devices and apps in use today, your business still needs a website. You just need it to be mobile. Head First Mobile Web walks you through the process of making a con......一起来看看 《Head First Mobile Web》 这本书的介绍吧!