-
Notifications
You must be signed in to change notification settings - Fork 0
Control Structures
Michael Wang edited this page Jan 20, 2025
·
1 revision
An if-else control block must begin with an if token, followed by a condition to evaluate, succeded by a then token.
if myCondition then
# your code here
Every if block thereafter must be followed by either a elif block, else block, or an end token.
The simplest if block is terminated by an end block. Consider the following example:
if myCondition then
# your code here
end
The simplest if...else blocks are declared as follows:
if myCondition then
# your code to be executed if myCondition is true
else
# your code to be executed if myCondition is false
end
Every if...elif...else block must begin as described above. Following every if block or elif block, you may either declare another elif block, an else block, or terminate the structure with a end block.