aboutsummaryrefslogtreecommitdiff
path: root/exercises/21_errors.zig
diff options
context:
space:
mode:
authorDave Gauer <ratfactor@gmail.com>2021-02-15 19:32:00 -0500
committerGitHub <noreply@github.com>2021-02-15 19:32:00 -0500
commit09fd739efa9cee151c8300f53c422d8a72766d49 (patch)
tree45f2eba30d72f43df60cd9b053ebaea5dfe11f18 /exercises/21_errors.zig
parent0d212ecf5a9de1c0bb673a2b6a409de5a99a9d7b (diff)
parent304489ca1f465b5456fa8c21dd0ae4e4c6c48617 (diff)
downloadziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.gz
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.bz2
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.xz
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.zip
Merge pull request #22 from quexxon/apply-zig-fmt
Apply `zig fmt` to exercises and generate remaining patch files
Diffstat (limited to 'exercises/21_errors.zig')
-rw-r--r--exercises/21_errors.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/exercises/21_errors.zig b/exercises/21_errors.zig
index 7714c4b..cbb5ac8 100644
--- a/exercises/21_errors.zig
+++ b/exercises/21_errors.zig
@@ -4,7 +4,7 @@
// In Zig, an error is a value. Errors are named so we can identify
// things that can go wrong. Errors are created in "error sets", which
// are just a collection of named errors.
-//
+//
// We have the start of an error set, but we're missing the condition
// "TooSmall". Please add it where needed!
const MyNumberError = error{
@@ -16,13 +16,13 @@ const MyNumberError = error{
const std = @import("std");
pub fn main() void {
- var nums = [_]u8{2,3,4,5,6};
+ var nums = [_]u8{ 2, 3, 4, 5, 6 };
for (nums) |n| {
std.debug.print("{}", .{n});
const number_error = numberFail(n);
-
+
if (number_error == MyNumberError.TooBig) {
std.debug.print(">4. ", .{});
}
@@ -40,7 +40,7 @@ pub fn main() void {
// Notice how this function can return any member of the MyNumberError
// error set.
fn numberFail(n: u8) MyNumberError {
- if(n > 4) return MyNumberError.TooBig;
- if(n < 4) return MyNumberError.TooSmall; // <---- this one is free!
+ if (n > 4) return MyNumberError.TooBig;
+ if (n < 4) return MyNumberError.TooSmall; // <---- this one is free!
return MyNumberError.TooFour;
}