当前位置:网站首页>Lua conditional statement
Lua conditional statement
2022-06-12 22:46:00 【o_ Guatian Lixia_ o】
lua Conditional statements
Conditional statements
Grammar format
# if sentence
if( Boolean expression )
then
--[ The Boolean expression is true The statement executed when --]
end
# if-else sentence
if( Boolean expression )
then
--[ The Boolean expression is true When the statement block is executed --]
else
--[ The Boolean expression is false When the statement block is executed --]
end
# if Nested statement
if( Boolean expression 1)
then
--[ Boolean expression 1 by true When the statement block is executed --]
if( Boolean expression 2)
then
--[ Boolean expression 2 by true When the statement block is executed --]
end
endexplain :lua in nil、false For false , The rest is true
if sentence
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 by true") end
0 by true
-- not nil:true
> if(not nil) then print("nil For false ") end
nil For false
if-else sentence
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 It's true ") else print("nil For false ") end
nil For false
if Nested statement
[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
边栏推荐
- Function introduction and common terms of ZABBIX
- PHP删除二维数组中相同项的数据
- Zabbix的功能介绍和常用术语
- Is there any risk in opening a securities account? How to open an account safely?
- C#读取word中表格数据
- Common rendering pipeline grooming
- Research Report on market supply and demand and strategy of tizanidine industry in China
- Wechat applet withdrawal function
- Introduction to Quaternion
- iShot
猜你喜欢

ShardingSphere-proxy-5.0.0部署之分表实现(一)

Shardingsphere-proxy-5.0.0 deployment table implementation (I)

JVM Basics - > how GC determines that an object can be recycled

JVM foundation > G1 garbage collector
![[probability theory and mathematical statistics] final review: formula summary and simple examples (end)](/img/f5/1c8392aaf87ea323524e94e3f213ed.png)
[probability theory and mathematical statistics] final review: formula summary and simple examples (end)

The shutter library recommends sizer to help you easily create a responsive UI

80 lines of code to realize simple rxjs
![[Part VI] source code analysis and application details of countdownlatch [key]](/img/6e/085e257c938a8c7b88c12c36df83e1.jpg)
[Part VI] source code analysis and application details of countdownlatch [key]
![[Part 7] source code analysis and application details of cyclicbarrier [key]](/img/bc/8ba2b86e599539a29683a63d02f0f7.jpg)
[Part 7] source code analysis and application details of cyclicbarrier [key]

iShot
随机推荐
[Part 8] semaphore source code analysis and application details [key points]
【LeetCode】102. Sequence traversal of binary tree
【LeetCode】300. Longest ascending subsequence
3.5 setup and teardown of test classes
JVM foundation > GC generation: minorgc majorgc fullgc mixed GC
Inventory of CV neural network models from 2021 to 2022
Coordinate transformation in pipelines
设计消息队列存储消息数据的 MySQL 表格
Introduction to Quaternion
【LeetCode】209. 长度最小的子数组
ImageView grayed, reflected, rounded, watermarked
RAID disk array
vim利用右下4键
Common rendering pipeline grooming
Is it safe to open an account with new bonds? How should novices operate?
[machine learning] learning notes 01- introduction
【LeetCode】300.最长上升子序列
Photoshop:ps how to enlarge a picture without blurring
Design of traceid in the project
Why is pain rating important?