Skip to content

Boolean

  • A Boolean can be either true or false.

Warning

Arithmetic does not apply to Booleans. Cannot use Booleans with Number or String.


Logical operators

Operator Description Usage
! Negation ! Bool
== Equal to Bool == Bool
!= Not equal to Bool != Bool
and And Bool and Bool
or Or Bool and Bool

Info

  • Logical comparisons return a Boolean.

  • and or can be chained as many as we like:

Bool and (Bool or Bool) and Bool or ...

Warning

Ordered comparisons such as > or < do not work for Booleans.

Example

1
2
3
4
5
println true == true;    // true
println true != false;   // true
println true and false;  // false
println  true or false ; // true
println true + false;    // Error because Booleans cannot be added