anon struct, union...
This commit is contained in:
@@ -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})}
|
||||
|
||||
Reference in New Issue
Block a user