当前位置:网站首页>lua 条件语句
lua 条件语句
2022-06-12 22:42:00 【o_瓜田李下_o】
lua 条件语句
条件语句
语法格式
# if 语句
if(布尔表达式)
then
--[ 在布尔表达式为 true 时执行的语句 --]
end
# if-else 语句
if(布尔表达式)
then
--[ 布尔表达式为 true 时执行该语句块 --]
else
--[ 布尔表达式为 false 时执行该语句块 --]
end
# if 嵌套语句
if( 布尔表达式 1)
then
--[ 布尔表达式 1 为 true 时执行该语句块 --]
if(布尔表达式 2)
then
--[ 布尔表达式 2 为 true 时执行该语句块 --]
end
end说明:lua中nil、false为假,其余均为真
if 语句
Lua 5.4.4 Copyright (C) 1994-2022 Lua.org, PUC-Rio
-- 2>1:true
> if(2>1) then print("2>1") end
2>1
-- 0:true
> if(0) then print("0为true") end
0为true
-- not nil:true
> if(not nil) then print("nil为假") end
nil为假
if-else 语句
Lua 5.4.4 Copyright (C) 1994-2022 Lua.org, PUC-Rio
-- 2<1:false
> if(2<1) then print("2<1") else print("2>=1") end
2>=1
-- nil:false
> if(nil) then print("nil为真") else print("nil为假") end
nil为假
if 嵌套语句
[email protected] ~ % cat test.lua
if(type(2)=='number') then
if(2>2) then
print("2>2")
else
if(2==2) then
print("2==2")
else
print("2<2")
end
end
end
[email protected] ~ % lua test.lua
2==2
边栏推荐
- China's new generation information technology industry "14th five year plan" special planning and innovation strategic direction report 2022 ~ 2028
- [proteus simulation] simple digital tube timer clock
- Colab教程(超级详细版)及Colab Pro/Colab Pro+使用评测
- QT quick 3D learning: use mouse and keyboard to control node position and direction
- [Part VI] source code analysis and application details of countdownlatch [key]
- 【LeetCode】209. 长度最小的子数组
- 【Web技术】1348- 聊聊水印实现的几种方式
- The development trend of digital collections!
- Research Report on market supply and demand and strategy of China's digital camera lens industry
- Is it safe to open an account for flush stock account
猜你喜欢

The annual salary of 500000 is one line, and the annual salary of 1million is another line

Colab教程(超级详细版)及Colab Pro/Colab Pro+使用评测

LNMP platform docking redis service

Web3 principle and decentralization

Colab tutorial (super detailed version) and colab pro/colab pro+ usage evaluation

Design a MySQL table for message queue to store message data

Database daily question --- day 10: combine two tables

Mysql concat_ WS, concat function use

Qt Quick 3D学习:鼠标拾取物体

Mysql case when then函数使用
随机推荐
[proteus simulation] simple digital tube timer clock
Sword finger offer series - 47 Maximum value of gifts
Dolphin-2.0.3 cluster deployment document
[890. find and replace mode]
[Part 8] semaphore source code analysis and application details [key points]
JVM Basics - > What are the thread shared areas in the JVM
Es6+ new content
Is it safe to open an account in tonghuashun? How to open an account for securities
2022-02-28 incluxdb high availability planning
【建议收藏】通俗易懂图解网络知识-第一篇
在同花顺开户安全么 ,证券开户怎么开户流程
C # reading table data in word
在同花顺开户证券安全吗,买股票怎么网上开户
【LeetCode】53.最大子数组和
【LeetCode】102. 二叉树的层序遍历
Flutter series part: detailed explanation of GridView layout commonly used in flutter
What you must know about cloud computing
China's new generation information technology industry "14th five year plan" special planning and innovation strategic direction report 2022 ~ 2028
Plusieurs camarades de classe de Tsinghua sont partis...
Ten key defensive points in the detailed attack and defense drill