Files
sx/examples/03-structs.sx
2026-02-09 18:07:41 +02:00

23 lines
523 B
Plaintext

#import "modules/std.sx";
Vec4 :: struct {
x, y, z, w: f32;
}
main :: () {
v1 : Vec4 = .{ 1, 2, 3, 0};
v2 := Vec4.{ 4, 1, 1, 3};
v3 := Vec4.{ w=0, x=2, y=3, z=4};
z := 5.0; // z is f32
w := 6.0; // w is f32
v4 := Vec4.{ y=3, x=9, w, z};
v4.y = 0;
print("v1: {}\nv2: {}\nv3: {}\nv4: {}\n", v1, v2, v3, v4);
}
// ** stdout **
//v1: Vec4{x:1.0, y:2.0, z:3.0, w:0.0}
//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}