And operation

Learn how to check if all conditions are true.

The logical and operation evaluates to true when both operands are true and false otherwise.

To use the and operator, place a && sign between two expressions:

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

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

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

Here is a practical example:

true and false // false
Try in Playground

Note that the and operation has higher precedence than the or 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 operator is evaluated first, and the result is used as the second operand of the or operator.