diff options
| author | Nate Cox <nate@natecox.dev> | 2026-06-17 18:37:14 -0700 |
|---|---|---|
| committer | Nate Cox <nate@natecox.dev> | 2026-06-17 18:37:14 -0700 |
| commit | 1aa1c0231c9129d2b361d6c21558a8dd1d508e82 (patch) | |
| tree | 5124ceded3f00e6c6d9114bd19a861b8297b218a /hello_world/src/root.zig | |
| download | zig-book-1aa1c0231c9129d2b361d6c21558a8dd1d508e82.tar.bz2 zig-book-1aa1c0231c9129d2b361d6c21558a8dd1d508e82.zip | |
Chapter one
Diffstat (limited to 'hello_world/src/root.zig')
| -rw-r--r-- | hello_world/src/root.zig | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/hello_world/src/root.zig b/hello_world/src/root.zig new file mode 100644 index 0000000..5a71250 --- /dev/null +++ b/hello_world/src/root.zig @@ -0,0 +1,18 @@ +//! By convention, root.zig is the root source file when making a package. +const std = @import("std"); +const Io = std.Io; + +/// This is a documentation comment to explain the `printAnotherMessage` function below. +/// +/// Accepting an `Io.Writer` instance is a handy way to write reusable code. +pub fn printAnotherMessage(writer: *Io.Writer) Io.Writer.Error!void { + try writer.print("Run `zig build test` to run the tests.\n", .{}); +} + +pub fn add(a: i32, b: i32) i32 { + return a + b; +} + +test "basic add functionality" { + try std.testing.expect(add(3, 7) == 10); +} |
