diff options
Diffstat (limited to 'example-container/Object.zig')
-rw-r--r-- | example-container/Object.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/example-container/Object.zig b/example-container/Object.zig new file mode 100644 index 0000000..22bc7a8 --- /dev/null +++ b/example-container/Object.zig @@ -0,0 +1,20 @@ +// File name starting with capital letters indicate a type definition. + +// Alias for this type. +const Self = @This(); + +// Struct fields. +id: i32, +op: u32 = 42, + +// Public static method, creating an Object. +pub fn init(v: i32) Self { + return Self{ .id = v }; +} + +// Public member function. +pub fn dump(self: Self) void { + const print = @import("std").debug.print; + print("Self = {s}\n", .{@typeName(Self)}); + print("ID = {} OP = {}\n", .{ self.id, self.op }); +} |