Keywords

Here is a list of all the keywords in the language.

Variable declaration

Keyword Description Example reference
let Declares a variable let x = 10 Variables
const Declares a constant const x = 10 Constants
type Declares a type alias type Foo = int Type Aliases

Control flow

Keyword Description Example reference
if Executes a block of code if a condition is true. if x == 10 { ... } If Statements
else Executes a block of code if a condition is false. if x == 10 { ... } else { ... } Else Statements
else if Executes a block of code if a condition is false and another condition is true. if x == 10 { ... } else if x == 20 { ... } Else If Statements
switch Executes a block of code based on the value of an expression. switch x { ... } Switch Statements

Loops

Keyword Description Example reference
while Executes a block of code while a condition is true. while x < 10 { ... } While Loops
for Executes a block of code for each element in a collection. for x in [1,2,3] { ... } For Loops
loop Executes a block of code forever. loop { ... } Loop Statements
break Breaks out of a loop. break Break Statements
continue Skips the rest of the current iteration of a loop. continue Continue Statements

Functions

Keyword Description Example reference
fun Declares a function. fun foo() { ... } Functions
return Returns a value from a function. return 10 Return Statements
overload Declares a function that overloads an operator. overload + (other: Foo): Foo { ... } Operator Overloading

Comments

Keyword Description Example reference
// Single line comment // this is a comment Comments
/* */ Multi line comment /* this is a comment */ Comments

Non Primitive Types

Keyword Description Example reference
struct Declares a struct. struct Foo { a: int } Structs
enum Declares an enum. enum Foo { Right, Left } Enums
impl Implements methods or traits for a type. impl Foo { fun foo() { ... } } Methods
trait Declares a trait. trait Foo { fun foo() } Traits
import Imports a module. import "std.io" Modules

Memory Management

Keyword Description Example reference
new Allocates memory on the heap. let x = new 5 Memory Management
as Casts a value to a different type. let x = 5 as float Casting
? Checks if a value is null. if x? { ... } Optionals

Error Handling

Keyword Description Example reference
try Executes a block of code that can throw an error. try { ... } Error Handling
catch Handles an error that occured inside a try block. catch err { ... } Catch
yeet Throws an error. yeet Error("error message") Yeet
error Declares an error type. error MyError { ... } Error Declaration
! Bang operator. let x = foo()! Bang