• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

      • latest /
      • Interfaces
    Kipper Docs
    • next
    • latest
    • 0.11.0
    • 0.10.4
    • 0.9.2
    • Overview

    • Quickstart

    • Goals for Kipper

    • Supported platforms

    • Usage Examples

      • Overview

      • Type Consistency

      • Runtime Type Casting

      • Strict Compiler Inspection

      • Integrated Runtime Library

    • 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

      • latest /
      • Interfaces
    • latest /
    • Interfaces

    Edit page

    Interfaces

    An interface is a type that defines a contract for the properties and methods that an object must implement. Interfaces are used to define the structure of an object without providing an implementation. This allows for the creation of objects that can be used interchangeably, as long as they implement the required properties and methods.

    See also Classes.

    Syntax

    interface IDENTIFIER {
        [ FIELD_DECLARATION ]
        [ METHOD_DECLARATION ]
    }

    Field Declaration

    IDENTIFIER: TYPE;

    Method Declaration

    IDENTIFIER(PARAMETER_LIST): RETURN_TYPE;

    Examples

    Simple interface definition

    interface Person {
        name: str;
        age: num;
        sayHello(): void;
    }

    Assigning an object to an interface

    interface Person {
        name: str;
        age: num;
        sayHello(): void;
    }
    var person: Person = {
        name: "Alice",
        age: 25,
        sayHello: (): void -> {
                print("Hello");
        }
    };
    
    person.sayHello(); // -> "Hello"

    Matching an interface

    See matches expression.

    interface Person {
        name: str;
        age: num;
        sayHello(): void;
    }
    
    var person: obj = {
        name: "Alice",
        age: 25,
        sayHello: (): void -> {
            print("Hello");
        }
    };
    
    if (person matches Person) {
        print("Person matches interface");
    }
  • 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.