• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

      • 0.10.4 /
      • Hidden Page
    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

    • 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

      • Relational Expressions

      • Convert Or Cast 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.10.4 /
      • Hidden Page
    • 0.10.4 /
    • Hidden Page

    Edit page

    F-String Expression

    F-String Expression is a string literal that is prefixed with f. It may contain replacement fields, which are expressions delimited by curly braces {}.

    This is the Kipper variant of templating/string formatting. It works by evaluating the expression inside the curly braces and replacing the curly braces and the expression with the result of the evaluation.

    f"Hello {name}!"

    The above expression will be evaluated to Hello World! if name is World.

    Syntax

    The syntax of F-String Expression is as follows:

    f"STR{EXP}STR";

    Every expression inside the curly braces will be evaluated and replaced with the result of the evaluation. The rest of the string will be left as is. Expressions may appear anywhere in the string, including the beginning and the end.

    Examples

    Simple F-String Expression

    var name: str = "World";
    print(f"Hello {name}!"); // -> "Hello World!"

    F-String Expression with multiple expressions

    var name: str = "World";
    var age: num = 42;
    print(f"Hello {name}! You are {age} years old."); // -> "Hello World! You are 42 years old."

    F-String Expression with expressions at the beginning and the end

    var name: str = "Kipper";
    print(f"{name} is the best!"); // -> "Kipper is the best!"

    Nested F-String Expression

    var name: str = "World";
    print(f"Hello {f"nested {name}"}!"); // -> "Hello nested World!"

    F-String Expression with escaped curly braces

    var name: str = "World";
    print(f"Hello {f"\{name\}"}!"); // -> "Hello {name}!"
  • 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.