• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

      • next /
      • Statements /
      • Do-While Loop
    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 /
      • Statements /
      • Do-While Loop
    • next /
    • Statements /
    • Do-While Loop

    Edit page

    Do-While Loop

    Do-while-loops are loops with a similar behaviour to while-loops, with the main difference being that do-while loops run the statement once before starting evaluating its condition. Afterwards the statement is only run if the specified condition is met.

    Syntax

    do STATEMENT while (CONDITION);

    Execution Schema

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

    Examples

    // ✓ Simple loop
    var var1: num = 0;
    do {
      var1++; // This statement is evaluated once at the start even if the condition isn't met
    } while (var1 >= 3);
    call print(f"'var1' is now '{var1}'"); // -> 'var1' is now '1'
    
    // ✓ Simple loop, where initially the condition isn't met but after the first run it becomes true
    var var2: num = 0;
    do {
      var2++;
    } while (var2 > 0 && var2 <= 25)
    call print(f"'var1' is now '{var2}'"); // -> 'var1' is now '26'
    
    // X Infinite Loop - Avoid this, as it results in your program freezing/running forever
    do {
      call print("An unnecessary print!");
    } while (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.