• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

      • next /
      • Datatypes /
      • Overview
    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 /
      • Datatypes /
      • Overview
    • next /
    • Datatypes /
    • Overview

    Edit page

    Overview - Datatypes

    As previously shown in the docs page Variables, every variable always has a type that defines what values it can store. This also means that you often can not mix variables of different data types together, as they fundamentally represent different things.

    What is a datatype?

    A data type defines the type of value, which can be stored in a variable or constant.

    A variable with the datatype num, for example, can only contain numbers. A variable with an str datatype can only contain text, symbols or numbers, but saves them as text. This makes them for example impossible to use for calculations and as such using them in arithmetic expression is invalid.

    Important

    Data types can not be mixed together and must be converted before being used with another type.

    ✓ VALID CODE

    // ✓ Valid
    var var1: str = "This ";
    var var2: str = "is ";
    var var3: str = "a string";
    var result: str = var1 + var2 + var3; // -> "This is a string"
    
    // ✓ Also Valid
    var var4: str = "42";
    var var5: num = (var4 as num) + 5; // Converts the string to 'num' and adds 5 to them
    
    // ✓ Also Valid
    var var6: num = 32;
    var var7: num = (var6 as num) \* 2; // Converts the string to 'num' and multiplies it by 2

    X INVALID CODE

    // X Invalid - May not re-define with new type signature
    var var1: str = "3";
    var var1: num = 3;
    
    // X Invalid - Invalid conversion from 'str' to 'num'
    var var2: str = "Obviously not a number";
    var var3: num = var4 as num; // Impossible to convert!
    
    // X Invalid - Invalid conversion from 'str' to 'num'
    var var2: str = ""; // empty
    var var3: num = var2 as num; // Impossible to convert, as it is an empty value!

    List of data types in Kipper

    • String Type - str
    • Number Type - num
    • Boolean Type - bool
    • Void Type - void
    • Null Type - null
    • Undefined Type - undefined
    • Array Type - Array<T>
  • 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.