Bool
Strict Boolean values, checked conditions, short circuit evaluation, explicit text conversion, and constant time scalar operations.
Bool is the built in Boolean value type. It requires no import and has exactly two values: true and false. Boolean conditions remain distinct from numbers, text, null, and collections.
Declaration and conditions
let enabled: Bool = true
let count = 3
let included = enabled && count > 0
if included {
print("included")
}
print(type(included)) // Bool
print(dtype(included)) // BoolAn omitted annotation infers Bool from a Boolean expression. A var Bool binding may be assigned another Boolean value; a let binding may not be reassigned. if and while require Bool. There is no implicit numeric truthiness: if 1, if "text", and if null are rejected by the checker.
Operators
| Operator | Result | Contract |
|---|---|---|
!value | Bool | Negate one Boolean value. |
left && right | Bool | Conjunction; evaluate right only when left is true. |
| `left | right` | |
left == right | Bool | Compare two Boolean values. |
left != right | Bool | Test whether two Boolean values differ. |
Operands require the stated concrete type. Arithmetic operators and numeric ordering do not accept Bool. Equality through Any and collection membership retain strict runtime types: true is distinct from integer 1, floating point 1.0, and String "true".
print(value) emits true or false. String(value) explicitly converts Bool to the corresponding lowercase text. cast<Bool>(value) checks that a value retained in Any is already Bool; it does not convert numbers or parse text. A Bool constructor accepting numbers or Strings is not provided.
Storage and complexity
A scalar Bool has bounded native storage. Scalar negation, equality, and the Boolean combination step use O(1) time and O(1) auxiliary space, excluding the cost of evaluating their operands. Short circuiting can skip that right hand evaluation entirely.
Typed arrays support the explicit Bool element datatype with one byte per element in native array storage. Boolean storage and operations remain subject to their own array reference contracts. Scalar Bool layout is not a binary interchange or ABI guarantee.
See Type inspection, Array, and the language operator reference.