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