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