diff options
author | Dave Gauer <dave@ratfactor.com> | 2021-03-12 18:59:46 -0500 |
---|---|---|
committer | Dave Gauer <dave@ratfactor.com> | 2021-03-12 18:59:46 -0500 |
commit | 6ad9774189fbd64b2f2c9519f4513ab34b0c3809 (patch) | |
tree | d6c90700131d5b28e898881f13e2a05612e4703f /exercises/30_switch.zig | |
parent | be36352572ddb18218e1830e49316c259dea5e8c (diff) | |
download | ziglings-6ad9774189fbd64b2f2c9519f4513ab34b0c3809.tar.gz ziglings-6ad9774189fbd64b2f2c9519f4513ab34b0c3809.tar.bz2 ziglings-6ad9774189fbd64b2f2c9519f4513ab34b0c3809.tar.xz ziglings-6ad9774189fbd64b2f2c9519f4513ab34b0c3809.zip |
"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/30_switch.zig')
-rw-r--r-- | exercises/30_switch.zig | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/exercises/30_switch.zig b/exercises/30_switch.zig deleted file mode 100644 index cb983f5..0000000 --- a/exercises/30_switch.zig +++ /dev/null @@ -1,53 +0,0 @@ -// -// The "switch" statement lets you match the possible values of an -// expression and perform a different action for each. -// -// This switch: -// -// switch (players) { -// 1 => startOnePlayerGame(), -// 2 => startTwoPlayerGame(), -// else => { -// alert(); -// return GameError.TooManyPlayers; -// } -// } -// -// Is equivalent to this if/else: -// -// if (players == 1) startOnePlayerGame(); -// else if (players == 2) startTwoPlayerGame(); -// else { -// alert(); -// return GameError.TooManyPlayers; -// } -// -const std = @import("std"); - -pub fn main() void { - const lang_chars = [_]u8{ 26, 9, 7, 42 }; - - for (lang_chars) |c| { - switch (c) { - 1 => std.debug.print("A", .{}), - 2 => std.debug.print("B", .{}), - 3 => std.debug.print("C", .{}), - 4 => std.debug.print("D", .{}), - 5 => std.debug.print("E", .{}), - 6 => std.debug.print("F", .{}), - 7 => std.debug.print("G", .{}), - 8 => std.debug.print("H", .{}), - 9 => std.debug.print("I", .{}), - 10 => std.debug.print("J", .{}), - // ... we don't need everything in between ... - 25 => std.debug.print("Y", .{}), - 26 => std.debug.print("Z", .{}), - // Switch statements must be "exhaustive" (there must be a - // match for every possible value). Please add an "else" - // to this switch to print a question mark "?" when c is - // not one of the existing matches. - } - } - - std.debug.print("\n", .{}); -} |