anon struct, union...

This commit is contained in:
agra
2026-02-09 19:22:53 +02:00
parent 55fc5790e4
commit 4b1c22d3b6
3 changed files with 203 additions and 9 deletions

View File

@@ -3,6 +3,15 @@ Vec4 :: struct {
x, y, z, w: f32;
}
Complex :: struct {
foo : union {
S: s32;
B: struct {
val: string;
};
} = .B.{val = "hello"};
}
main :: () {
v1 : Vec4 = .{ 1, 2, 3, 0};
v2 := Vec4.{ 4, 1, 1, 3};
@@ -13,6 +22,9 @@ main :: () {
v4.y = 0;
print("v1: {}\nv2: {}\nv3: {}\nv4: {}\n", v1, v2, v3, v4);
complex : Complex = .{};
print("\n{}\n", complex);
}
// ** stdout **
@@ -20,3 +32,5 @@ main :: () {
//v2: Vec4{x:4.0, y:1.0, z:1.0, w:3.0}
//v3: Vec4{x:2.0, y:3.0, z:4.0, w:0.0}
//v4: Vec4{x:9.0, y:3.0, z:5.0, w:6.0}
//
//Complex{foo: .B(Complex.foo.B{val: hello})}