Name

! (logical NOT)

Description

Inverts the Boolean value of an expression. Returns true if the expression is false and returns false if the expression is true. If the expression (a>b) evaluates to true, then !(a>b) evaluates to false.

Examples

  • size(400, 400);
    boolean a = false;
    if (!a) {
      rect(120, 80, 200, 200);
    }
    if (a) {
      line(80, 40, 360, 320);
      line(80, 320, 360, 40);
    }
    Image output for example 1
  • size(400, 400);
    boolean a = true;
    if (!a) {
      rect(120, 80, 200, 200);
    }
    if (a) {
      line(80, 40, 360, 320);
      line(80, 320, 360, 40);
    }
    Image output for example 2

Syntax

  • !expression

Parameters

  • expressionany valid expression