| 1 | const std = @import("std"); |
| 2 | |
| 3 | const Foo = union { |
| 4 | float: f32, |
| 5 | int: u32, |
| 6 | }; |
| 7 | |
| 8 | pub fn main() void { |
| 9 | var f = Foo{ .int = 42 }; |
| 10 | f = Foo{ .float = undefined }; |
| 11 | bar(&f); |
| 12 | std.debug.print("value: {}\n", .{f.float}); |
| 13 | } |
| 14 | |
| 15 | fn bar(f: *Foo) void { |
| 16 | f.float = 12.34; |
| 17 | } |
| 18 | |
| 19 | // exe=succeed |