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

Logical Operators

The logical operators combine two bool values into a bool.

  • && logical conjunction
  • || logical disjunction

Process

At runtime:

  1. the left operand is evaluated;
  2. if its value already determines the result, that value is the expression's value, and nothing further is evaluated; and
  3. otherwise, the right operand is evaluated, and its value is the expression's value.

Assertions

  1. Both operands have type bool, and the result has type bool.

Syntax

logical_conjunction_operator = ampersand_ampersand ;

logical_disjunction_operator = vertical_bar_vertical_bar ;