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 FalseOperators
-
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 executesSide()(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)gives1,int(false)gives0, andfloat/float32/float64work the same way (float(true)is1.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 rewritex != 0.
Notes
- Interpolation and
printboth outputTrue/Falsedirectly. - For how bool equality relates to the language-wide equality story, see Equality and Hashing.
Last updated on October 11, 2026
