• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

      • 0.9.2 /
      • While-loop
    Kipper Docs
    • next
    • latest
    • 0.11.0
    • 0.10.4
    • 0.9.2
    • Overview

    • Quickstart

    • Goals for Kipper

    • Supported platforms

    • Usage Examples

    • Kipper Compiler

    • Variables

    • Datatypes

    • Expressions

    • Statements

    • If-statement

    • While-loop

    • Do-While-loop

    • For-Loop

    • Functions

    • Comments

    • Built-in Functions

      • 0.9.2 /
      • While-loop
    • 0.9.2 /
    • While-loop

    Edit page

    While-loop

    While-loops are code blocks that are executed multiple times as long as the specified CONDITION is met. The behaviour of while-loops is very similar to do-while-loops, and in some cases it even might be better to use do-while than while-loops, so watch out for opportunities to replace while-loops with do-while loops.

    Released in v0.10.0 - Please update your version to access this feature.

    Syntax

    while (CONDITION) STATEMENT;

    Execution Schema

    • Check CONDITION, if it exists, before running the STATEMENT. If CONDITION is false, then the loop will be stopped!
    • Run STATEMENT if CONDITION was true.

    Examples

    // ✓ Simple loop
    var var1: num = 0;
    while (var1 <= 5) {
      var1++;
    }
    call print(f"'var1' is now '{var1}'"); // -> 'var1' is now '6'
    
    
    // ✓ Simple loop, without braces
    var var2: num = 0;
    while (var2 > 0 && var2 <= 25)
      var2++;
    call print(f"'var1' is now '{var2}'"); // -> 'var1' is now '0'
    
    // X Infinite Loop - Avoid this, as it results in your program freezing/running forever
    while (true) {
      call print("An unnecessary print!");
    }
  • 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.