Data types: bool

Represents a boolean value.

Type syntax

bool

Literal syntax

true

false

Discussion

Operands with this data type are intended to store either the value true or false. The literals can be used within expressions wherever a bool operand is expected. The type name bool, in turn, is designated to be used in declarations of data members. For example:

var bool initialized = false;

Logical operations

You can combine a bool operand with other operands to logical expressions. The following table provides an overview of the possible operations:

Operator

Short description

!

Logical NOT

&&

Logical AND

||

Logical OR

Comparison operations

You can compare two bool operands in order to test whether these are equal or not. The following table provides an overview of the possible operations:

Operator

Short description

==

Equality test for two bool operands.

!=

Inequality test for two bool operands.

Type conversions

Chora reacts sensitive when mixing operands of different data types within an operation. To avoid compiler warnings or even errors you can convert the affected operands explicitly by using adequate type conversion operators. Wherever it is not ambiguous, the Chora compiler applies the necessary type conversion implicitly.

In case of boolean expressions Chora supports type conversion between all of the existing data types and bool as destination type. The basic principle in this case is that source values equal 0 (zero) are considered as boolean false value while all non-zero values are considered as true values. For more details see Conversion to bool value.