Browse documentation
Data structures

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

aner
let enabled: Bool = true
let count = 3
let included = enabled && count > 0
if included {
    print("included")
}
print(type(included))  // Bool
print(dtype(included)) // Bool

An 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

OperatorResultContract
!valueBoolNegate one Boolean value.
left && rightBoolConjunction; evaluate right only when left is true.
`leftright`
left == rightBoolCompare two Boolean values.
left != rightBoolTest 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.

Aner documentation · Reference and guides