0PricingLogin
Zig Academy · Lesson

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

  1. Importing Files with @import
  2. Structuring a Multi-File Project
  3. build.zig.zon and the Package Manager
  4. Adding a Third-Party Module
← Back to Zig Academy