Added add function
parent
f39ebe66f2
commit
9ab6cc6be2
16
main.zig
16
main.zig
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue