Added add function

main
2wenty1ne 2024-11-06 14:41:06 +01:00
parent f39ebe66f2
commit 9ab6cc6be2
1 changed files with 11 additions and 5 deletions

View File

@ -15,17 +15,23 @@ fn Vec3(comptime T: type) type {
} }
fn print(this: Self) !void { 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 { pub fn main() !void {
var vec1: Vec3(u64) = undefined; var vec1: Vec3(u64) = undefined;
var vec2: Vec3(u64) = undefined;
vec1.init(2, 4, 3); vec1.init(2, 4, 3);
vec1.print(); vec2.init(1, 1, 1);
try vec1.print();
vec1.add(vec2);
try vec1.print();
} }