A Bool can be either
Gleam defines a handful of operators that work with Bools.
False && False // => False False && True // => False True && False // => False True && True // => True False || False // => False False || True // => True True || False // => True True || True // => True
|| are short circuiting, meaning they don't evaluate the right
hand side if they don't have to.
&& evaluates the right hand side if the left hand side is
|| evaluates the right hand side if the left hand side is
Gleam supports negation of Bools using either the
! operator or the
bool.negate function from the
!True // => False !False // => True
While written in the code using a capital letter, they are represented at
runtime with the atoms
false, making them compatible with Elixir
and Erlang's booleans.
This is important if you want to use Gleam and Elixir or Erlang together in one project.
// Gleam True False
% Erlang true. false.