Name

|| (logical OR)

Description

Compares two expressions and returns true if one or both evaluate to true. Returns false only if both expressions are false. The following list shows all possible combinations:

true || false // Evaluates true because the first is true
false || true // Evaluates true because the second is true
true || true // Evaluates true because both are true
false || false // Evaluates false because both are false

Examples

  • size(400, 400);
    
    for (int i = 20 ; i <= 380; i += 20) {
      if ((i < 140) || (i > 240)) {
        line(120, i, 320, i);
      }
    }
    Image output for example 1

Syntax

  • expression1 || expression2

Parameters

  • expression1any valid expression
  • expression2any valid expression