Booleans
Calibre uses bool for values that are either true or false.
let open : bool = true;let locked := false;Booleans are commonly produced by comparisons.
let a := 10;let b := 20;
print(a < b); // trueprint(a = b); // falseprint(a != b); // trueYou can combine boolean expressions with &&, ||, and !.
let age := 20;let mut has_ticket := false;
// true - `!` inverses the value of the boolhas_ticket := !has_ticket
// true - `&&` represents `and` therefore is only true when both its inputs are truelet can_enter := age >= 18 && has_ticket;
// false - `||` represents `or` therefore is only true when one of its inputs are truelet needs_help := !has_ticket || age < 18;Booleans are often used with if expressions.
const can_vote := fn (age : int) -> bool => age >= 18;
const main := fn => { if can_vote(21) => print("allowed") else => print("not allowed");};Many standard library functions also return booleans, such as "calibre".starts_with("cal") or list:<int>[1, 2, 3].contains(2).