• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

      • 0.11.0 /
      • Expressions /
      • Logical Expressions
    Kipper Docs
    • next
    • latest
    • 0.11.0
    • 0.10.4
    • 0.9.2
    • Overview

    • Quickstart

    • Goals for Kipper

    • Supported platforms

    • Usage Examples

      • Overview

      • Compiler Setup

        • Overview

          • index

          • compiler

          • errors

          • logger

          • utils

          • config

          • index

          • index

        • Overview

        • new

        • run

        • compile

        • help

        • version

    • Variables

      • Overview

      • String Type

      • Number Type

      • Boolean Type

      • Void Type

      • Null Type

      • Undefined Type

      • Array Type

      • Overview

      • Arithmetic Expression

      • Assignment Expression

      • Conditional Expressions

      • Logical Expressions

      • Bitwise Expression

      • Relational Expressions

      • Convert Expression

      • F-String Expression

      • Member Access Expression

      • Function Call Expression

      • Overview

      • Expression Statement

      • If Statement

      • While Loop

      • Do-While Loop

      • For Loop

      • Compound Statement

      • Jump Statement

    • Functions

    • Comments

    • Built-in Functions

      • 0.11.0 /
      • Expressions /
      • Logical Expressions
    • 0.11.0 /
    • Expressions /
    • Logical Expressions

    Edit page

    Logical Expressions

    Logical expressions combine two or more expressions/conditions and evaluate to a bool value (Either true or false) based on the specific operator used.

    The NOT operator (!) is also a logical operator, even though unlike the other operators it can be only used on a single expression, and can be used to invert the result of a logical expression.

    Syntax

    Logical AND and Logical OR

    EXP ( && | || ) EXP

    Logical NOT

    !VALUE;

    Examples

    Logical AND

    // Logical AND - All must be true
    true && true; // -> true
    false && true; // -> false
    true && false; // -> false
    false && false; // -> false

    Logical OR

    // Logical OR - One must be true
    true || true; // -> true
    false || true; // -> true
    true || false; // -> true
    false || false; // -> false

    Logical NOT

    // Logical NOT - Negate
    !false; // -> true
    !true; // -> false

    Chained Logical Expressions

    Logical Expressions may be also chained together as long as you want. For example:

    // Chained Logical AND - All must be true
    true && true && true; // -> true
    true && false && true; // -> false
    
    // Chained Logical OR - One must be true
    true || true || true; // -> true
    true || false || true; // -> true
    false || false || false; // -> false

    Logical Expressions & Relational Expressions

    You can also combine relational expressions with logical expressions, like this for example:

    // ✓ Combined relational and logical expressions
    (3 == 4 && 3 != 4) || (2 != 22 && 3 == 3);
    
    // Following the order of precedence:
    // -> (false && true) || (true && true)
    // -> (false) || (true)
    // -> true
  • Developed at:

    • Releases
    • GitHub
    • Security
    • Issue Tracker
    • License
  • Copyright © 2021-2025 Luna Klatzer, 2024-2025 Lorenz Holzbauer & Fabian Baitura.
    Kipper is licensed under the GPL-3.0-or-later license.