58 - come back to this later for better understanding

This commit is contained in:
Adam Millerchip 2021-12-31 23:34:45 +09:00
parent ada65eb79a
commit 65b308aadc
1 changed files with 4 additions and 4 deletions

View File

@ -192,8 +192,8 @@ const TripItem = union(enum) {
// 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 @@ 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;
@ -309,7 +309,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);