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