if / elseif / else
Executes code based on a condition.
Syntax
if condition then ... elseif ... else ... end
Description
Written with then and end. Not equal is written with ~= (not !=). Keywords and/or/not are used.
Example
Loading editor…
Expected output
Passed
When to use?
Flow branching.
Common mistakes
- ⚠️ Not equal is ~=, NOT !=. Blocks are closed with end.