Skip to main content
Version: 1.4.0

Comparing

Boolean values are the result of comparisons of values. Numbers and strings are completely ordered. Booleans can be compared for equality. Two values need to be of the same type to be compared, but not all values of the same type can be compared: only those with comparable types (a concept directly lifted from Michelson) such as int, nat, string, and bool itself. The comparison operators are overloaded so they are defined on all comparable types.

const a : bool = 1 == 1; // equality (true)
const b : bool = 1 != 0; // inequality (true)
const c : bool = 1 > 0; // greater than (true)
const d : bool = 0 < 1; // lower than (true)
const e : bool = 0 >= 0; // greater than or equal (true)
const f : bool = 0 <= 0; // lower than or equal (true)