Classes

Classes are general-purpose, flexible constructs that become the building blocks of your program’s code.

Definition Syntax

class Base {
ty: string
static new(): Base {
return Base {
ty: "Base",
};
}
baseCall() {
print("base call");
}
virtual printName() {
print("name")
}
}

Static Field

class Color {
static const Red = "#FF0000"
}

Get access to the static field:

print(Color.Red)

Initialization

conat base = Base.new();

Or

conat base = Base { ty: "base" };

Inheritance

class Child extends Base {
name: string
static new(): Child {
return Child {
...Base.new(),
name: "Hello World",
};
}
virtual setName(value: string) {
this.name = value;
}
override printName() {
print("name: ", this.name)
}
}