diff options
| author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-05-04 17:15:30 +0200 |
|---|---|---|
| committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-05-04 17:15:30 +0200 |
| commit | 8af3372cf204861f8541f91e47543f1b33337c5b (patch) | |
| tree | a333fe8d515ae8fad19a94e37bdc4649f6dd662c /exercises/058_quiz7.zig | |
| parent | 1ba1e301a8a977f652157ca60a0522c95bc736aa (diff) | |
fixed removed array multiplication
Diffstat (limited to 'exercises/058_quiz7.zig')
| -rw-r--r-- | exercises/058_quiz7.zig | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/exercises/058_quiz7.zig b/exercises/058_quiz7.zig index fda83fc..d3b677b 100644 --- a/exercises/058_quiz7.zig +++ b/exercises/058_quiz7.zig @@ -224,11 +224,10 @@ const NotebookEntry = struct { // +---+----------------+----------------+----------+ // const HermitsNotebook = struct { - // Remember the array repetition operator `**`? It is no mere - // novelty, it's also a great way to assign multiple items in an - // array without having to list them one by one. Here we use it to - // initialize an array with null values. - entries: [place_count]?NotebookEntry = .{null} ** place_count, + // Remember the array repetition function @splat()? It is a great way + // to assign multiple items in an array without having to list them + // one by one. Here we use it to initialize an array with null values. + entries: [place_count]?NotebookEntry = @splat(null), // The next entry keeps track of where we are in our "todo" list. next_entry: u8 = 0, @@ -409,7 +408,7 @@ pub fn main() void { // aside memory for the trip and have the hermit's notebook fill // in the trip from the destination back to the path. Note that // this is the first time we've actually used the destination! - var trip = [_]?TripItem{null} ** (place_count * 2); + var trip: [place_count * 2]?TripItem = @splat(null); notebook.getTripTo(trip[0..], destination) catch |err| { print("Oh no! {}\n", .{err}); |
