• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

      • next /
      • Classes
    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 /
      • Classes
    • next /
    • Classes

    Edit page

    Classes

    A class is an object-oriented structure similar to an interface which defines a specific type of object. It can contain properties and methods that define the behavior of the object, which can be altered by a setup method called constructor.

    See also Interfaces.

    Syntax

    class IDENTIFIER {
        [ FIELD_DECLARATION ]
        [ METHOD_DECLARATION ]
        [ CONSTRUCTOR_DECLARATION ]
    }

    Field Declaration

    IDENTIFIER: TYPE;

    Method Declaration

    IDENTIFIER(PARAMETER_LIST): RETURN_TYPE {
        STATEMENT
    }

    Constructor Declaration

    constructor(PARAMETER_LIST) {
        STATEMENT
    }

    Examples

    Simple class definition

    class Person {
        name: str;
        age: num;
    
        constructor(name: str, age: num) {
            this.name = name;
            this.age = age;
        }
    
        sayHello(): void {
            print("Hello, my name is " + this.name + " and I am " + this.age + " years old.");
        }
    }
    
    var person: Person = new Person("Alice", 25);
    person.sayHello(); // -> "Hello, my name is Alice and I am 25 years old."
  • 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.