Skip to content

Builtin Operators

Calibre has several built-in operators that show up throughout the language.

The in operator checks membership.

if 4 in [4, 16, 32] => print("found");

You will also see in used in patterns and overloaded forms.

let classify := fn match int -> str {
in 0..20 => "in-range",
in [30, 40, 50] => "in-list",
_ => "other"
};

The ternary operator has the form condition ? when_true : when_false.

This is useful for short conditional expressions.

let label := (10 > 5) ? "yes" : "no";
print(label);

Exponentiation uses **.

let squared := 5 ** 2;
let root := 9 ** 0.5;

Logical and and or use && and || respectively.

These operators often appear together with comparisons and boolean conditions.

if age >= 18 && has_ticket => print("allowed");
if x < 0 || y < 0 => print("negative found");

Calibre also supports operator overloading for some of these forms, but even without overloading they are part of the everyday surface of the language and are used heavily in conditions, comprehensions, and pattern matching.