Control Flow: If Expressions
In Zig, if statements can also be used as expressions (similar to the ternary operator in other languages).
zig const age = 18; if (age >= 18) { std.debug.print("Adult\n", .{}); } else { std.debug.print("Minor\n", .{}); }
// As an expression const status = if (age >= 18) "Adult" else "Minor";
Note: There is no truthy/falsy logic. Only boolean values are accepted in the condition.