Atom

Numbers and truthiness

Compare zero with false and null

Use the boolean type conversion to see how a value acts in a condition.

Atom
print(convert(bool, 0))
print(convert(bool, false))
print(convert(bool, null))
Output
true
false
false

Zero is a number and is true in a condition. Only false and null count as false.

Choose numbers for calculation and booleans for decisions. A missing value is represented by 'null'.

Null

A missing dictionary key yields 'null'. Use 'value ?? fallback' when you want a fallback only for a missing value.

Booleans

'true' and 'false' are literal values. In a condition, only 'false' and 'null' are false. Zero and empty collections are true.

Integers

Integer literals can be decimal, hexadecimal, or binary. Atom starts with signed 64-bit integers. Use a type descriptor and 'convert' when an external format needs a specific width.

Floating-point numbers

A decimal point or exponent makes a floating-point literal. Floating-point values use binary64 by default. Division and exponentiation produce binary64 results.

Decimal, hexadecimal and binary integer literals fit in signed 64 bits. Floating-point literals use binary64 and a locale-independent decimal separator. The decimal form supports an exponent and requires digits after the decimal point. Null and false are false in conditions. All other values are true.