Pyro

A dynamically-typed, garbage-collected scripting language.

Version 0.16.14

Conditional Expressions


Pyro supports conditional expressions using if, e.g.

var size = if value < 100 {
    "small"
} else {
    "large"
};

The syntax of an if expression is:

if <condition-expression> {
    <if-true-expression>
} else {
    <if-false-expression>
}

An if expression is different from an if statement — an if expression requires an else clause and the {} blocks must each contain a single expression.

As you'd expect, if expressions support chained else if clauses, e.g.

var size = if value < 100 {
    "small"
} else if value < 1000 {
    "medium"
} else {
    "large"
};