Skip to Content

Bool

bool has exactly two values, printed as True and False (leading capitals).

val on = true; print(on, false); print(1 < 2, 3 == 4);
True False True False

Operators

  • Equality: == / != compare by value and are the only comparison operators on bool; ordering comparisons are not allowed.

  • No bitwise logic: & | ^ do not take bool; the only logical combinations are && || !, with short-circuit evaluation: false && Side() never executes Side() (see Operators).

bool is the only legal type in condition position. Numbers are not “true when nonzero”, strings are not “true when non-empty”; conditions must be written out explicitly (see Conditions):

error MS3101: Type mismatch: expected 'bool', got 'int32'.

Conversions

  • int(true) gives 1, int(false) gives 0, and float / float32 / float64 work the same way (float(true) is 1.0); explicit conversion from bool to numbers is legal.
  • The reverse does not exist: bool(1) reports MS3249, and the diagnostic directly suggests the idiomatic rewrite x != 0.

Notes

  • Interpolation and print both output True / False directly.
  • For how bool equality relates to the language-wide equality story, see Equality and Hashing.
Last updated on October 11, 2026