12345678910111213141516171819202122232425262728293031 |
- --- exercises/058_quiz7.zig 2023-10-03 22:15:22.125574535 +0200
- +++ answers/058_quiz7.zig 2023-10-05 20:04:07.106101152 +0200
- @@ -192,8 +192,8 @@
- // Oops! The hermit forgot how to capture the union values
- // in a switch statement. Please capture both values 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}),
- }
- }
- };
- @@ -255,7 +255,7 @@
- // 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;
- @@ -309,7 +309,7 @@
- //
- // 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);
-
|