Skip to main content

Boolean/Bool (true/false)

A bool is a truth value and can only be true or false. Boolean values are mostly produced in combination with comparison operators. For example, when comparing one value with another, the result is either true or false.

truthy and falsy

Not only values of the data type bool contain a truth value. Objects of all other data types also have a value property referred to as truthy or falsy. In the context of logical operators and branching, it is important to know when a value is considered true or false. Here is a list of all values that are falsy and are therefore treated as false: null, the value of the Null data type false ▪ the number 0 (Integer) or 0.0 (Float) ▪ an empty string ” ” ▪ an empty list [ ] ▪ an empty map All other values are treated as truthy.

Converting to boolean

Other base types can be converted to boolean: