Bool
The Bool type represents boolean values: true and false.
Booleans are used in conditionals, pattern matching, and logical operations.
Literals
true / false
Bool
The two boolean literal values.
is-active? = true
is-disabled? = false
println is-active?
# => true
Operators
and / &&
Bool -> Bool -> Bool
Logical AND. Returns
true only if both operands are true.
Short-circuits: if the first operand is false, the second is not evaluated.
println (true && true) # => true
println (true && false) # => false
println (false && true) # => false
or / ||
Bool -> Bool -> Bool
Logical OR. Returns
true if either operand is true.
Short-circuits: if the first operand is true, the second is not evaluated.
println (true || false) # => true
println (false || true) # => true
println (false || false) # => false
not / !
Bool -> Bool
Logical NOT. Returns the opposite boolean value.
println (not true) # => false
println (not false) # => true
println (!true) # => false
Comparison
Bool.eq?
Bool -> Bool -> Bool
Returns
true if both boolean values are the same.
println (Bool.eq? true true) # => true
println (Bool.eq? true false) # => false
println (true == true) # => true
Bool.ne?
Bool -> Bool -> Bool
Returns
true if the boolean values are different.
println (Bool.ne? true false) # => true
println (Bool.ne? true true) # => false
println (true != false) # => true
Conversions
Bool.show
Bool -> String
Converts a boolean to its string representation.
println (Bool.show true) # => "true"
println (Bool.show false) # => "false"
Bool.force
Bool -> Bool
Forces evaluation of a boolean value. Useful for strict evaluation in lazy contexts.
b = Bool.force true
println b
# => true
Pattern Matching with Booleans
While you can use if/then/else with booleans,
pattern matching is often cleaner for complex logic.
describe = fn(active, admin) =>
match (active, admin)
| (true, true) -> "Active admin"
| (true, false) -> "Active user"
| (false, _) -> "Inactive"
println (describe true true)
# => "Active admin"
Conditionals
Booleans are commonly used with if/then/else expressions.
status = fn(logged-in) =>
if logged-in then "Welcome!" else "Please log in"
println (status true)
# => "Welcome!"