diff --git a/main.zig b/main.zig index 9f450e0..e3884cd 100644 --- a/main.zig +++ b/main.zig @@ -15,17 +15,23 @@ fn Vec3(comptime T: type) type { } fn print(this: Self) !void { - try writer.print("X: %d\nY: %d\nZ: %d\n", .{this.x, this.y, this.x}); + try writer.print("X: {d}\nY: {d}\nZ: {d}\n", .{this.x, this.y, this.z}); } - //fn add(this: *Self, other: Self) { - // - //} + fn add(this: *Self, other: Self) void { + this.x = this.x + other.x; + this.y = this.y + other.y; + this.z = this.z + other.z; + } }; } pub fn main() !void { var vec1: Vec3(u64) = undefined; + var vec2: Vec3(u64) = undefined; vec1.init(2, 4, 3); - vec1.print(); + vec2.init(1, 1, 1); + try vec1.print(); + vec1.add(vec2); + try vec1.print(); }