Skip to content

Commit e0a50e9

Browse files
committed
continue
1 parent bd014f3 commit e0a50e9

6 files changed

Lines changed: 12 additions & 12 deletions

File tree

.progress.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
54
1+
58

exercises/055_unions.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ pub fn main() void {
5959
std.debug.print("Insect report! ", .{});
6060

6161
// Oops! We've made a mistake here.
62-
printInsect(ant, AntOrBee.c);
63-
printInsect(bee, AntOrBee.c);
62+
printInsect(ant, AntOrBee.a);
63+
printInsect(bee, AntOrBee.b);
6464

6565
std.debug.print("\n", .{});
6666
}

exercises/056_unions2.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ pub fn main() void {
4444
std.debug.print("Insect report! ", .{});
4545

4646
// Could it really be as simple as just passing the union?
47-
printInsect(???);
48-
printInsect(???);
47+
printInsect(ant);
48+
printInsect(bee);
4949

5050
std.debug.print("\n", .{});
5151
}
5252

5353
fn printInsect(insect: Insect) void {
54-
switch (???) {
54+
switch (insect) {
5555
.still_alive => |a| std.debug.print("Ant alive is: {}. ", .{a}),
5656
.flowers_visited => |f| std.debug.print("Bee visited {} flowers. ", .{f}),
5757
}

exercises/057_unions3.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//
1616
const std = @import("std");
1717

18-
const Insect = union(InsectStat) {
18+
const Insect = union(enum) {
1919
flowers_visited: u16,
2020
still_alive: bool,
2121
};

exercises/058_quiz7.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ const TripItem = union(enum) {
192192
// Oops! The hermit forgot how to capture the union values
193193
// in a switch statement. Please capture each value as
194194
// 'p' so the print statements work!
195-
.place => print("{s}", .{p.name}),
196-
.path => print("--{}->", .{p.dist}),
195+
.place => |p| print("{s}", .{p.name}),
196+
.path => |p| print("--{}->", .{p.dist}),
197197
}
198198
}
199199
};
@@ -255,7 +255,7 @@ const HermitsNotebook = struct {
255255
// dereference and optional value "unwrapping" look
256256
// together. Remember that you return the address with the
257257
// "&" operator.
258-
if (place == entry.*.?.place) return entry;
258+
if (place == entry.*.?.place) return &entry.*.?;
259259
// Try to make your answer this long:__________;
260260
}
261261
return null;
@@ -309,7 +309,7 @@ const HermitsNotebook = struct {
309309
//
310310
// Looks like the hermit forgot something in the return value of
311311
// this function. What could that be?
312-
fn getTripTo(self: *HermitsNotebook, trip: []?TripItem, dest: *Place) void {
312+
fn getTripTo(self: *HermitsNotebook, trip: []?TripItem, dest: *Place) TripError!void {
313313
// We start at the destination entry.
314314
const destination_entry = self.getEntry(dest);
315315

exercises/059_integers.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const print = @import("std").debug.print;
2020

2121
pub fn main() void {
2222
const zig = [_]u8{
23-
0o131, // octal
23+
0o65, // octal
2424
0b1101000, // binary
2525
0x66, // hex
2626
};

0 commit comments

Comments
 (0)