Skip to content

Instantly share code, notes, and snippets.

@ryuukk

ryuukk/test.zig Secret

Created October 23, 2020 15:41
Show Gist options
  • Save ryuukk/b9ad558420f475d3021b7c9ac1090727 to your computer and use it in GitHub Desktop.
Save ryuukk/b9ad558420f475d3021b7c9ac1090727 to your computer and use it in GitHub Desktop.
const Node = struct {
id: []const u8,
parent: ?*Node = null,
};
pub fn main() anyerror!void {
var something = true;
var a = Node{ .id = "a" };
var b = Node{ .id = "b", .parent = &a };
if (something) {
if (b.parent) |p| {
std.log.info("{} {}", .{ b.id, p.id });
}
}
// vs
if (something and b.parent) |p| {
std.log.info("{} {}", .{ b.id, p.id });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment