📅  最后修改于: 2020-10-16 05:13:45             🧑  作者: Mango
决策结构要求程序员确定一个或多个要由程序评估或测试的条件,以及要确定的条件为真的情况下要执行的一条或多条语句,如果条件为真,则可选地指定要执行的其他语句。条件确定为假。
以下是大多数编程语言中常见的典型决策结构的一般形式-
Lua编程语言假定布尔值true和non-nil的任何组合为true ,并且如果它是布尔值false或nil ,则将其假定为false值。要注意的是,在Lua中,零将被认为是正确的。
Lua编程语言提供以下类型的决策声明。
Sr.No. | Statement & Description |
---|---|
1 | if statement
An if statement consists of a boolean expression followed by one or more statements. |
2 | if…else statement
An if statement can be followed by an optional else statement, which executes when the boolean expression is false. |
3 | nested if statements
You can use one if or else if statement inside another if or else if statement(s). |