Bool Type
The Bool type represents logical truth values, with only two literals: true and false. Boolean values are commonly used in conditional judgments and logical operations.
Cangjie supports three logical operators: logical NOT ! (negation), logical AND && (true only when both are true), and logical OR || (true when at least one is true). Comparison operators (>, <, ==, !=, >=, <=) also produce Bool type results. The Bool type does not support arithmetic operations.
The code on the right demonstrates boolean value declarations and logical operations. Logical AND and OR use short-circuit evaluation: when the left operand can already determine the result, the right operand won't be evaluated. Try adding a combined expression like println(x > y && y > 0) and observe the effect of short-circuit evaluation.
&& and logical OR || use short-circuit evaluation: when the left operand can already determine the result, the right operand won't be evaluated.