Modules

Modules #

👉 Modules were introduced in 0.11

Modules are seperate RocketLang files can be imported using the import statement. Functions and variables starting with a uppercase name are then available in the imported module.

For example take this module:

// fixtures/module.rl
a = 1
A = 5

Sum = def (a, b)
    return a + b
end

You can import it with:

import("fixtures/module")

This results in a variable module implicitly being assigned. You can use it like so:

🚀 > import("fixtures/module")
=> nil
🚀 > module.a
=> nil
🚀 > module.A
=> 5
🚀 > module.Sum(module.A, 2)
=> 7