booleans
As with Boolean types in other programming languages, bool
s have only two possible values: true
and false
.
fn main() {
let t: bool = true;
let true_expr = 5 == 5;
assert(t == true_expr, 'this is true');
let f: bool = false;
let false_expr = 7 == 5;
assert(f == false_expr, 'this is false');
}
As with other scalar types, they are one felt252
in size.
Try it out!
- Install the toolchain:
- For macOS and Linux, run our script:
curl -sL https://raw.githubusercontent.com/lambdaclass/cairo-by-example/main/build/installer.sh | bash -s 2.2.0
- For Windows and others, please see the official guide
- Run the example:
- Copy the example into a booleans.cairo file and run with:
%!s(<nil>) booleans.cairo