Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (27 sloc) 935 Bytes
Modules, upon modules, upon modules... is this Node?


Imports are extremely useful for modularizing your code. The import statement is used to import code from other Caboose files. The import statement syntax is as so:

import "./path/to/your/file.cb"

{% hint style="info" %} The import location is relative to where you run the interpreter from. For example, if you run your code from /home/user/project and your main file is in ./main.cb and it imports code from "./math.cb", the file math.cb must be in the same folder as main.cb. {% endhint %}


{% code-tabs %} {% code-tabs-item title="example_import.cb" %}

import "./example_imported_file.cb"

print add(1, 2); // Prints 3

{% endcode-tabs-item %}

{% code-tabs-item title="example_imported_file.cb" %}

fun add(a, b) {
    return a + b;

{% endcode-tabs-item %} {% endcode-tabs %}

You can’t perform that action at this time.