Djinn Lang

Interfaces

Defined Types

Interfaces define contracts which a struct requires to implement. To define interface, use the keyword interface preceding it name.

interface User {
    string name;
    i32 age;
}

Interfaces are allowed to collide with struct names. In this following example, interface User will not be anbugious with struct User. The compiler will use interface declaration for parameters, methods return values and anywhere needs instead the struct implementation

interface User {
    string name;
    i32 age;

    bool isOnline();
}

struct User : User{
    string name;
    i32 age;

    bool isOnline(){
      return true;
    }
}

On this page