aboutsummaryrefslogtreecommitdiff
path: root/exercises/09_if.zig
diff options
context:
space:
mode:
Diffstat (limited to 'exercises/09_if.zig')
-rw-r--r--exercises/09_if.zig32
1 files changed, 32 insertions, 0 deletions
diff --git a/exercises/09_if.zig b/exercises/09_if.zig
new file mode 100644
index 0000000..28ac712
--- /dev/null
+++ b/exercises/09_if.zig
@@ -0,0 +1,32 @@
+//
+// Now we get into the fun stuff, starting with the 'if' statement!
+//
+// if (true) {
+// ...
+// } else {
+// ...
+// }
+//
+// Zig has the "usual" comparison operators such as:
+//
+// a == b means "a equals b"
+// a < b means "a is less than b"
+// a !=b means "a does not equal b"
+//
+// The important thing about Zig's "if" is that it *only* accepts
+// boolean values. It won't coerce numbers or other types of data
+// to true and false.
+//
+const std = @import("std");
+
+pub fn main() void {
+ const foo = 1;
+
+ // Please fix this condition:
+ if (foo) {
+ // We want out program to print this message!
+ std.debug.print("Foo is 1!\n", .{});
+ } else {
+ std.debug.print("Foo is not 1!\n", .{});
+ }
+}