mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-12-21 21:53:11 -05:00
056-058 completed
This commit is contained in:
parent
30d90e0019
commit
7108f89eb3
3 changed files with 6 additions and 5 deletions
|
@ -1,2 +1,3 @@
|
|||
# Ziglings
|
||||
|
||||
# ⚠️ My solutions, not the [original exercises](https://codeberg.org/ziglings/exercises)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
//
|
||||
const std = @import("std");
|
||||
|
||||
const Insect = union(InsectStat) {
|
||||
const Insect = union(enum) {
|
||||
flowers_visited: u16,
|
||||
still_alive: bool,
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue