Conditional Statements
Create branching paths through a program.
Conditional statements allow RapidScript program to execute different lines of code based on whether the specified condition evaluates to true
.
If statement
The condition
is an expression that evaluates to a bool
value. This can be: a bool
literal, a bool
variable, an expression using an operator (comparison, relational, or logical), or a function call with a bool
return value.
The code within the {}
only executes if the condition
evaluates to true
.
Else statement
If there is code to execute only when the condition does not evaluate to true, then an else
statement can be added containing the desired code. The code in the else
block will only execute if the condition
evaluates to false
.
Else-If statement
If there is more than one case to account for, then an else if
statement can be added. The else if
has its own condition, and will only execute its code block if all previous conditions evaluated to false
and its own condition evaluates to true
. The else block only executes if all of the preceding conditions evaluate to false
. Multiple else if
statements may be added.
Nested If statement
If statements may also be nested within each other.
Last updated