Skip to content

Values and Types

Utku Melemetci edited this page May 17, 2024 · 2 revisions

There are three basic types in the language: Char, Int, and Bool. They're what you expect. There is actually a secret fourth type, Unit, but you probably won't have to worry about it. It usually arises from the inferred type of functions that don't return anything.

Do note that you can't actually create a Char: you can only create Char*, a pointer to characters, by using a string literal. Similarly, Int* and Bool* technically exist, but you can't create them.

Here is an example program:

func main() {
    let a: Char* = "Hi! It is the year"
    let b: Int = 2024
    let c = "Are you amazing?"
    let d: Bool = true
}

The type of c is inferred--the compiler will figure out what the types are in most cases if you don't provide them. Annotations are required for function definitions, though.

func a(b: Int) -> Int {
    return 1
}

If you don't provide a return type, Unit, meaning "returns nothing," will be assumed.

Clone this wiki locally