SplitScript reference / Language / is

is

keyword

expression is pattern

Tests a value against a pattern.

is evaluates its left operand exactly once and returns bool. It accepts the same recursive patterns as match, but a mismatch simply produces false and therefore needs no exhaustive fallback. Bindings exist only on control-flow paths where the match is proven: the true edge of a direct test, the false edge after !, the following operand of && or || when short-circuiting proves it, and the corresponding if branch, while body, or guarded match arm. Storing or passing the boolean discards that proof. Write !(value is pattern) to negate the complete test.

Examples

Bind a value on the matching path

if value is Some(number) && number > 0 {
    print(number)
}

Use the binding on a negated condition's else path

if !(value is Some(number)) {
    return 0
} else {
    return number
}