summaryrefslogtreecommitdiff
path: root/exercises/010_if2.zig
diff options
context:
space:
mode:
authorDave Gauer <dave@ratfactor.com>2021-03-12 18:59:46 -0500
committerDave Gauer <dave@ratfactor.com>2021-03-12 18:59:46 -0500
commit0956f1839fcaaa273353148da9e157a8f9690d2f (patch)
treed6c90700131d5b28e898881f13e2a05612e4703f /exercises/010_if2.zig
parent93eefe0f250bb76bfdd8e6bb784b6a9586517000 (diff)
"999 is enough for anybody" triple-zero padding (#18)
When I hit 999 exercises, I will finally have reached the ultimate state of soteriological release and no more exercises will be needed. The cycle will be complete. All that will be left is perfect quietude, freedom, and highest happiness.
Diffstat (limited to 'exercises/010_if2.zig')
-rw-r--r--exercises/010_if2.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/exercises/010_if2.zig b/exercises/010_if2.zig
new file mode 100644
index 0000000..d0c8cac
--- /dev/null
+++ b/exercises/010_if2.zig
@@ -0,0 +1,16 @@
+//
+// If statements are also valid expressions:
+//
+// var foo: u8 = if (a) 2 else 3;
+//
+const std = @import("std");
+
+pub fn main() void {
+ var discount = true;
+
+ // Please use an if...else expression to set "price".
+ // If discount is true, the price should be $17, otherwise $20:
+ var price: u8 = if ???;
+
+ std.debug.print("With the discount, the price is ${}.\n", .{price});
+}