mirror of
https://github.com/ziglang/zig.git
synced 2024-11-14 16:13:24 +00:00
20 lines
295 B
Zig
20 lines
295 B
Zig
const std = @import("std");
|
|
|
|
const Foo = union {
|
|
float: f32,
|
|
int: u32,
|
|
};
|
|
|
|
pub fn main() void {
|
|
var f = Foo{ .int = 42 };
|
|
f = Foo{ .float = undefined };
|
|
bar(&f);
|
|
std.debug.print("value: {}\n", .{f.float});
|
|
}
|
|
|
|
fn bar(f: *Foo) void {
|
|
f.float = 12.34;
|
|
}
|
|
|
|
// exe=succeed
|