Created
May 29, 2021 17:50
-
-
Save haze/9fbc2728f5c7623b70d829abafc6375f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn main() anyerror!void { | |
@import("std").log.info("x={}", .{try foo(23)}); | |
} | |
fn foo(x: usize) !?Union { | |
if (x > 5) return Union.x; | |
return bar(); | |
} | |
fn bar() !?Union { | |
return null; | |
} | |
const Enum = enum { x, y, z }; | |
const Union = union(Enum) { x, y, z }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment