mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-30 04:44:44 +00:00
731 B
731 B
module
Erg allows you to think of the file itself as a single record. This is called a module.
# foo.er
.i = 1
# Defining the foo module is almost the same as defining this record
foo = {.i = 1}
#bar.er
foo = import "foo"
print! foo # <module 'foo'>
assert foo.i == 1
Since module types are also record types, deconstruction assignment is possible.
{sin; cos; ...} = import "math"
module visibility
└─┬ ./src
├─ lib.er
├─ foo.er
├─bar.er
└─┬ bar
├─ baz.er
└─ qux.er