diff --git a/README.md b/README.md index f42d9dd..272852b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Ziglings + # ⚠️ My solutions, not the [original exercises](https://codeberg.org/ziglings/exercises) diff --git a/exercises/057_unions3.zig b/exercises/057_unions3.zig index a5017d2..0c3c3b2 100644 --- a/exercises/057_unions3.zig +++ b/exercises/057_unions3.zig @@ -15,7 +15,7 @@ // const std = @import("std"); -const Insect = union(InsectStat) { +const Insect = union(enum) { flowers_visited: u16, still_alive: bool, }; diff --git a/exercises/058_quiz7.zig b/exercises/058_quiz7.zig index cf32fc3..1fc5d85 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 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);