PR3L-Uebung-VectorSelf/main.zig

32 lines
702 B
Zig
Raw Normal View History

2024-11-05 16:14:43 +01:00
const std = @import("std");
const writer = std.io.getStdOut().writer();
const expect = std.testing.expect;
fn Vec3(comptime T: type) type {
return struct {
const Self = @This();
x: T,
y: T,
z: T,
fn init(this: *Self, x: T, y: T, z: T) void {
this.x = x;
this.y = y;
this.z = z;
}
fn print(this: Self) !void {
try writer.print("X: %d\nY: %d\nZ: %d\n", .{this.x, this.y, this.x});
}
//fn add(this: *Self, other: Self) {
//
//}
};
}
pub fn main() !void {
var vec1: Vec3(u64) = undefined;
vec1.init(2, 4, 3);
vec1.print();
}