当前位置:网站首页>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
边栏推荐
- Colab教程(超级详细版)及Colab Pro/Colab Pro+使用评测
- A 42 year old senior executive of a large factory reminds people aged 30-39 that these six habits that make you stronger should be developed as soon as possible
- Step by step evolution of restful API version Frankel
- 【LeetCode】33. Search rotation sort array
- Flutter库推荐Sizer 可帮助您轻松创建响应式 UI
- 细数攻防演练中十大关键防守点
- Design a MySQL table for message queue to store message data
- [image denoising] image denoising based on trilateral filter with matlab code
- Is it safe to open an account in tonghuashun? How to open an account for securities
- 【LeetCode】300.最长上升子序列
猜你喜欢
![[image denoising] image denoising based on trilateral filter with matlab code](/img/f2/770a0e2938728e731c18c0a66f7c12.png)
[image denoising] image denoising based on trilateral filter with matlab code

Mysql concat_ws、concat函数使用

Mysql concat_ WS, concat function use

【Web技术】1348- 聊聊水印实现的几种方式
![[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]

LNMP platform docking redis service

Flutter库推荐Sizer 可帮助您轻松创建响应式 UI

JVM foundation - > talk about class loader two parent delegation model

2022 heavyweight: growth law - skillfully use digital marketing to break through enterprise difficulties

Qrcodejs2 QR code generation JS
随机推荐
China barcode decoder market trend report, technical innovation and market forecast
QT quick 3D learning: mouse picking up objects
【890. 查找和替换模式】
[image denoising] image denoising based on trilateral filter with matlab code
Huawei officially entered the "front loading" stage, and the millimeter wave radar track entered the "localization +4d" cycle
USB机械键盘改蓝牙键盘
【LeetCode】102. Sequence traversal of binary tree
【LeetCode】209. Minimum length subarray
LeetCode —— 26. Remove duplicates from an ordered array
flutter系列之:flutter中常用的GridView layout详解
Mysql case when then函数使用
Theory + practice will help you master the dynamic programming method
项目里面的traceID的设计
Flutter库推荐Sizer 可帮助您轻松创建响应式 UI
JS fighting on...
Database daily question --- day 10: combine two tables
JVM foundation > GC generation: minorgc majorgc fullgc mixed GC
The annual salary of 500000 is one line, and the annual salary of 1million is another line
【LeetCode】53. Maximum subarray and
Ten key defensive points in the detailed attack and defense drill