-
-
Save ryuukk/b9ad558420f475d3021b7c9ac1090727 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
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