Conditionnal Statements

Used where code needs to be executed based on a run-time.

If

Run code if a condition is True. Otherwise it skip the expression and run the rest of the function.

Nested if are possible to check different conditions if only when other conditions are evaluated to True.

Synopsis

(if (<condition>) {
    <expression-true>
)

The condition must be a boolean variable or expression, the expression will be run if the condition is True.

Example:

(func (doc (int c))
{
    (if (2 == c) {
        (c = 1);
    })
    (c);
})
(test 2)

In this example, the code in the if statement will be called only if c is equal to the value 2.

Here is an example of nested if's:

(func (doc (int c) (int v))
{
    (if (2 == c) {
        (if ((v + c) == 42) {
            (c = 1);
        })
    })
    (c);
})
(test 2)

We check two things:

So we can add nested if depending of our needed.

Last updated