• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

      • next /
      • Expressions /
      • Assignment Expression
    Kipper Docs
    • next
    • latest
    • 0.11.0
    • 0.10.4
    • 0.9.2
    • Overview

    • Quickstart

    • Goals for Kipper

    • Supported platforms

    • Usage Examples

      • Overview

    • Variables

      • Overview

      • String Type

      • Number Type

      • Boolean Type

      • Void Type

      • Null Type

      • Undefined Type

      • Array Type

      • Overview

      • Tangled Expression

      • Arithmetic Expression

      • Assignment Expression

      • Conditional Expressions

      • Logical Expressions

      • Bitwise Expression

      • Relational Expressions

      • Convert Or Cast Expression

      • F-String Expression

      • Member Access Expression

      • Function Call Expression

      • Lambda Expression

      • Matches Expression

      • Overview

      • Expression Statement

      • If Statement

      • While Loop

      • Do-While Loop

      • For Loop

      • Compound Statement

      • Jump Statement

    • Functions

    • Interfaces

    • Classes

    • Comments

    • Built-in Functions

      • Overview

      • Compiler Setup

        • Overview

          • index

          • compiler

          • errors

          • logger

          • utils

          • config

          • index

          • index

        • Overview

        • new

        • run

        • compile

        • help

        • version

      • next /
      • Expressions /
      • Assignment Expression
    • next /
    • Expressions /
    • Assignment Expression

    Edit page

    Assignment Expression

    Assignment expressions are used to assign a value to a variable. They may also be chained based on their order of precedence, where each item is one by one evaluated.

    Syntax

    Simple Assignment

    NAME = EXP

    Operator Modified Assignment

    Besides the regular assignment, there are also operators that modify the value of the variable by the value of the expression. These operators are +=, -=, *=, /=, **= and %=. These acts like arithmetic expressions and assignments combined.

    NAME ( += | -= | *= | /= | **= | %= ) EXP

    Examples

    Assigning a value to a variable

    var var1: num = 0;
    
    // Re-assigned the value of var1
    var1 = 3;

    Chaining assignment expressions

    var x: num = 5;
    var y: num = 5;
    var z: num = 5;
    
    // Chained assignment expressions
    x = y = z = 1;
    
    // All of these should now output "1"
    print(x as str);
    print(y as str);
    print(z as str);

    Operator Modified Assignment

    var x: num = 5;
    
    // Operator modified assignment
    x += 5; // x = x + 5
    x -= 5; // x = x - 5
    x *= 5; // x = x * 5
    x /= 5; // x = x / 5
    x **= 5; // x = x ** 5
    x %= 5; // x = x % 5
  • 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.