mirror of
https://codeberg.org/ziglings/exercises.git
synced 2025-06-08 01:57:02 +09:00
19 lines
587 B
Diff
19 lines
587 B
Diff
--- exercises/046_optionals2.zig 2024-11-08 22:46:25.592875338 +0100
|
|
+++ answers/046_optionals2.zig 2024-11-08 22:46:20.699447951 +0100
|
|
@@ -22,7 +22,7 @@
|
|
|
|
const Elephant = struct {
|
|
letter: u8,
|
|
- tail: *Elephant = null, // Hmm... tail needs something...
|
|
+ tail: ?*Elephant = null, // Hmm... tail needs something...
|
|
visited: bool = false,
|
|
};
|
|
|
|
@@ -66,6 +66,6 @@
|
|
|
|
// HINT: We want something similar to what `.?` does,
|
|
// but instead of ending the program, we want to exit the loop...
|
|
- e = e.tail ???
|
|
+ e = e.tail orelse break;
|
|
}
|
|
}
|