Skip to content

Toppings / Imports

Import code from other files.

Creating a Topping

math_utils.choco:

fn square(x) {
    return x * x;
}

fn cube(x) {
    return x * x * x;
}

Importing a Topping

main.choco:

import math_utils;

print square(5);   // 25
print cube(3);     // 27

The import statement executes the module file and makes its functions available.