Importing Files with @import
Bring another source file into scope.
Bring In Another File
Code grows, so you split it across files. The built-in @import pulls another Zig source file into the current one. 📦
const math = @import("math.zig");It Returns a Value
@import is an expression that gives back a value. You store it in a const, then reach into it with dot access just like a struct.
const math = @import("math.zig");
const r = math.add(2, 3);All lessons in this course
- Importing Files with @import
- Structuring a Multi-File Project
- build.zig.zon and the Package Manager
- Adding a Third-Party Module