当前位置:网站首页>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
end
explain :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
- Alcohol detector based on 51 single chip microcomputer
- 微信小程序提现功能
- JVM foundation - > three ⾊ mark
- [leetcode] the k-largest element in the array
- Gb28181 protocol -- alarm
- JVM foundation > G1 garbage collector
- 【LeetCode】102. Sequence traversal of binary tree
- 【建议收藏】通俗易懂图解网络知识-第一篇
- Plusieurs camarades de classe de Tsinghua sont partis...
猜你喜欢
数字藏品的发展趋势!
数据库每日一题---第10天:组合两个表
Colab tutorial (super detailed version) and colab pro/colab pro+ usage evaluation
be careful! Your Navicat may have been poisoned
SQL query list all views in SQL Server 2005 database - SQL query to list all views in an SQL Server 2005 database
[data analysis] data clustering and grouping based on kmeans, including Matlab source code
[image denoising] image denoising based on trilateral filter with matlab code
Modstartcms modular station building system v3.3.0 component function upgrade, event triggering enhancement
Design a MySQL table for message queue to store message data
Mysql case when then函数使用
随机推荐
Is it safe to open an account in tonghuashun? How to open an account for securities
JS fighting on...
C#读取word中表格数据
USB机械键盘改蓝牙键盘
Hostvars in ansible
lua 日期时间
細數攻防演練中十大關鍵防守點
What you must know about cloud computing
The programmer dedicated to promoting VIM has left. Father of vim: I will dedicate version 9.0 to him
[890. find and replace mode]
Is there any risk in opening a securities account? How to open an account safely?
C language: how to give an alias to a global variable?
China Aquatic Fitness equipment market trend report, technical innovation and market forecast
四元数简介
2022-02-28 incluxdb high availability planning
web3 原则和去中心化
VIM use the lower right 4 keys
项目里面的traceID的设计
42岁大厂高管,给30岁-39岁人提个醒:这6个让你变强的习惯,要尽快养成
China embolic coil market trend report, technical innovation and market forecast