Or operation

Learn how to check if at least one condition is true.

The logical or operation evaluates to true when at least one of the operands is true and false otherwise.

To use the or operator, place a || sign between two expressions:

/*<value>*/ || /*<value>*/
Try in Playground

For a more natural language feel, you can use or:

/*<value>*/ or /*<value>*/
Try in Playground

Here is a practical example:

true or false // true
Try in Playground

Note that the or operation has lower precedence than the and operation:

true or false and false
Try in Playground

The above expression is equivalent to the following:

true or (false and false)
Try in Playground

In other words, the and operation is evaluated first, and the result is used as the second operand of the or operation.