Skip to content
mystborn edited this page Jun 22, 2018 · 2 revisions

An if statement allows you to perform an action if a certain condition is met. An if statement takes the following form:

if(condition) <statement>

If the condition is met, the body is executed. If you want something to happen if the condition isn't met, then you can add an else to end of the if block like so:

if(condition) <statement> else <statement>

For example:

if(i == 0)
    zero = true;
else
    zero = false;

if(name == "Chris") {
    print("Hello, Chris");
} else if(name == "Bob") {
    print("Hello, Bob");
} else {
    print("Who are you?");
}
Clone this wiki locally