mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-12-21 21:53:11 -05:00
Merge pull request 'Nobody wants the long version of finding out if a variable is set.' (#94) from minor_improvements into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/94
This commit is contained in:
commit
49c54fb075
2 changed files with 7 additions and 10 deletions
|
@ -51,8 +51,6 @@ fn visitElephants(first_elephant: *Elephant) void {
|
||||||
// We should stop once we encounter a tail that
|
// We should stop once we encounter a tail that
|
||||||
// does NOT point to another element. What can
|
// does NOT point to another element. What can
|
||||||
// we put here to make that happen?
|
// we put here to make that happen?
|
||||||
if (e.tail == null) ???;
|
e = e.tail ???
|
||||||
|
|
||||||
e = e.tail.?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- exercises/046_optionals2.zig 2023-10-03 22:15:22.122241138 +0200
|
--- exercises/046_optionals2.zig 2024-05-10 23:11:25.796632478 +0200
|
||||||
+++ answers/046_optionals2.zig 2023-10-05 20:04:07.049433424 +0200
|
+++ answers/046_optionals2.zig 2024-05-10 23:10:16.115335668 +0200
|
||||||
@@ -21,7 +21,7 @@
|
@@ -21,7 +21,7 @@
|
||||||
|
|
||||||
const Elephant = struct {
|
const Elephant = struct {
|
||||||
|
@ -9,12 +9,11 @@
|
||||||
visited: bool = false,
|
visited: bool = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@
|
@@ -51,6 +51,6 @@
|
||||||
// We should stop once we encounter a tail that
|
// We should stop once we encounter a tail that
|
||||||
// does NOT point to another element. What can
|
// does NOT point to another element. What can
|
||||||
// we put here to make that happen?
|
// we put here to make that happen?
|
||||||
- if (e.tail == null) ???;
|
- e = e.tail ???
|
||||||
+ if (e.tail == null) break;
|
+ e = e.tail orelse break;
|
||||||
|
|
||||||
e = e.tail.?;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue