Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Boolean Type

The Boolean type is denoted by Bool and is used to represent logical true and false values.

Boolean Literals

The Boolean type has only two literals: true and false.

The following example demonstrates the use of Boolean literals:

let a: Bool = true
let b: Bool = false

Supported Operations for Boolean Type

Boolean types support the following operators: logical operators (logical NOT !, logical AND &&, logical OR ||), partial relational operators (== and !=), and partial compound assignment operators (&&= and ||=).