SultanC
  1. Home
  2. Examples
  3. Control flow

Conditions with if and else

control_flow/conditions.sn
def absolute(value: int): int {
    if (value < 0) {
        return 0 - value;
    } else {
        return value;
    };
}

def main(): int {
    return absolute(-42);
}

Run it

With the interpreter, without compiling:

./build/sultanc run examples/en/control_flow/conditions.sn

Or compile it to an executable:

./build/sultanc examples/en/control_flow/conditions.sn -o build/example && ./build/example

Source on GitHub   All examples