summaryrefslogtreecommitdiff
path: root/exercises/058_quiz7.zig
diff options
context:
space:
mode:
authorIbrahim Muftee <ibrahim@muftee.net>2026-06-29 15:11:40 -0500
committerIbrahim Muftee <ibrahim@muftee.net>2026-06-29 15:15:14 -0500
commitbdfe3df2947f8787c8a4ef8c534f6a8932e13871 (patch)
treef2df9a5f56b6c7f95c0978a861cb0ecf60560391 /exercises/058_quiz7.zig
parentd093f37e1e4c5aed4a4c8d4999001134aec251ca (diff)
feat: begin solving exercises
Diffstat (limited to 'exercises/058_quiz7.zig')
-rw-r--r--exercises/058_quiz7.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/exercises/058_quiz7.zig b/exercises/058_quiz7.zig
index d3b677b..f7d231d 100644
--- a/exercises/058_quiz7.zig
+++ b/exercises/058_quiz7.zig
@@ -192,8 +192,8 @@ const TripItem = union(enum) {
// Oops! The hermit forgot how to capture the union values
// in a switch statement. Please capture each value as
// 'p' so the print statements work!
- .place => print("{s}", .{p.name}),
- .path => print("--{}->", .{p.dist}),
+ .place => |p| print("{s}", .{p.name}),
+ .path => |p| print("--{}->", .{p.dist}),
}
}
};
@@ -254,7 +254,7 @@ const HermitsNotebook = struct {
// dereference and optional value "unwrapping" look
// together. Remember that you return the address with the
// "&" operator.
- if (place == entry.*.?.place) return entry;
+ if (place == entry.*.?.place) return &entry.*.?;
// Try to make your answer this long:__________;
}
return null;
@@ -308,7 +308,7 @@ const HermitsNotebook = struct {
//
// Looks like the hermit forgot something in the return value of
// this function. What could that be?
- fn getTripTo(self: *HermitsNotebook, trip: []?TripItem, dest: *Place) void {
+ fn getTripTo(self: *HermitsNotebook, trip: []?TripItem, dest: *Place) TripError!void {
// We start at the destination entry.
const destination_entry = self.getEntry(dest);