Nested If Statements In Lua
# Lua Nested if Statements
[ Lua Flow Control](#)
* * *
## if...else Statement
Lua if statements allow nesting, which means you can insert other if or else if statements within an if or else if statement.
### Lua nested if statement syntax is as follows:if( boolean expression 1)then -- if(boolean expression 2) then -- endend
You can nest **else if...else** statements in the same way.
### Example
The following example is used to check the values of variables a and b:
## Example
--
a =100;
b =200;
--
if( a ==100)
then
--
if( b ==200)
then
--
print("The value of a is 100 and the value of b is 200");
end
end
print("The value of a is :", a );
print("The value of b is :", b );
The output of the above code is as follows:
The value of a is 100 and the value of b is 200 The value of a is :100 The value of b is :200
[ Lua Flow Control](#)
YouTip