当前位置:网站首页>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
边栏推荐
- JVM foundation > CMS garbage collector
- Wechat applet withdrawal function
- Mysql case when then函数使用
- Su embedded training day13 - file IO
- JVM foundation > GC generation: minorgc majorgc fullgc mixed GC
- ShardingSphere-proxy-5.0.0部署之分表实现(一)
- Alcohol detector based on 51 single chip microcomputer
- Photoshop:PS如何实现放大图片不模糊
- PHP删除二维数组中相同项的数据
- Is it safe to open an account in tonghuashun? How to open an account for securities
猜你喜欢

Hostvars in ansible

C#读取word中表格数据

Hostvars in ansible

SQL query list all views in SQL Server 2005 database - SQL query to list all views in an SQL Server 2005 database

Design a MySQL table for message queue to store message data

Mysql concat_ws、concat函数使用

The programmer dedicated to promoting VIM has left. Father of vim: I will dedicate version 9.0 to him

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

be careful! Your Navicat may have been poisoned

The carrying capacity of L2 level ADAS increased by more than 60% year-on-year in January, and domestic suppliers "emerged"
随机推荐
JVM foundation - > what is STW?
[890. find and replace mode]
生成小程序菊花码(生成菊花码、更换中间logo、更改图片尺寸,加文字)
C#读取word中表格数据
Use of map() function in JS
JVM foundation > CMS garbage collector
[leetcode] sword finger offer II 020 Number of palindrome substrings
Report on the "fourteenth five year plan" and strategic strategy recommendations for China's intellectual property protection industry 2022 ~ 2028
42岁大厂高管,给30岁-39岁人提个醒:这6个让你变强的习惯,要尽快养成
Analysis report on the "fourteenth five year plan" and the latest development trend of China's medical information industry from 2022 to 2028
2022-02-28 incluxdb high availability planning
MySQL case when then function use
The annual salary of 500000 is one line, and the annual salary of 1million is another line
MOOG servo valve d634-341c/r40ko2m0nss2
China embolic coil market trend report, technical innovation and market forecast
JVM foundation - > talk about class loader two parent delegation model
[machine learning] learning notes 01- introduction
Flutter series part: detailed explanation of GridView layout commonly used in flutter
Coordinate transformation in pipelines
Colab tutorial (super detailed version) and colab pro/colab pro+ usage evaluation