···2626 // This function needs to return any error which might come back from detect().
2727 // Please use a "try" statement rather than a "catch".
2828 //
2929- var x = detect(n);
2929+ const x = detect(n);
30303131 return x + 5;
3232}
+2-2
exercises/029_errdefer.zig
···21212222pub fn main() void {
2323 // We simply quit the entire program if we fail to get a number:
2424- var a: u32 = makeNumber() catch return;
2525- var b: u32 = makeNumber() catch return;
2424+ const a: u32 = makeNumber() catch return;
2525+ const b: u32 = makeNumber() catch return;
26262727 std.debug.print("Numbers: {}, {}\n", .{ a, b });
2828}
+1-1
exercises/039_pointers.zig
···24242525pub fn main() void {
2626 var num1: u8 = 5;
2727- var num1_pointer: *u8 = &num1;
2727+ const num1_pointer: *u8 = &num1;
28282929 var num2: u8 = undefined;
3030
+1-1
exercises/048_methods2.zig
···24242525 pub fn print(self: *Elephant) void {
2626 // Prints elephant letter and [v]isited
2727- var v: u8 = if (self.visited) 'v' else ' ';
2727+ const v: u8 = if (self.visited) 'v' else ' ';
2828 std.debug.print("{u}{u} ", .{ self.letter, v });
2929 }
3030};
+1-1
exercises/049_quiz6.zig
···37373838 pub fn print(self: *Elephant) void {
3939 // Prints elephant letter and [v]isited
4040- var v: u8 = if (self.visited) 'v' else ' ';
4040+ const v: u8 = if (self.visited) 'v' else ' ';
4141 std.debug.print("{u}{u} ", .{ self.letter, v });
4242 }
4343};
+2-2
exercises/055_unions.zig
···53535454pub fn main() void {
5555 // We'll just make one bee and one ant to test them out:
5656- var ant = Insect{ .still_alive = true };
5757- var bee = Insect{ .flowers_visited = 15 };
5656+ const ant = Insect{ .still_alive = true };
5757+ const bee = Insect{ .flowers_visited = 15 };
58585959 std.debug.print("Insect report! ", .{});
6060
···273273 // distance) than the one we'd noted before. If it is, we
274274 // overwrite the old entry with the new one.
275275 fn checkNote(self: *HermitsNotebook, note: NotebookEntry) void {
276276- var existing_entry = self.getEntry(note.place);
276276+ const existing_entry = self.getEntry(note.place);
277277278278 if (existing_entry == null) {
279279 self.entries[self.end_of_entries] = note;
···386386 // "start" entry we just added) until we run out, at which point
387387 // we'll have checked every reachable Place.
388388 while (notebook.hasNextEntry()) {
389389- var place_entry = notebook.getNextEntry();
389389+ const place_entry = notebook.getNextEntry();
390390391391 // For every Path that leads FROM the current Place, create a
392392 // new note (in the form of a NotebookEntry) with the
···83838484pub fn main() void {
8585 // This is a real duck!
8686- var ducky1 = Duck{
8686+ const ducky1 = Duck{
8787 .eggs = 0,
8888 .loudness = 3,
8989 };
90909191 // This is not a real duck, but it has quack() and waddle()
9292 // abilities, so it's still a "duck".
9393- var ducky2 = RubberDuck{
9393+ const ducky2 = RubberDuck{
9494 .in_bath = false,
9595 };
96969797 // This is not even remotely a duck.
9898- var ducky3 = Duct{
9898+ const ducky3 = Duct{
9999 .diameter = 17,
100100 .length = 165,
101101 .galvanized = true,
+1-1
exercises/072_comptime7.zig
···39394040 // This gets the digit from the "instruction". Can you
4141 // figure out why we subtract '0' from it?
4242- comptime var digit = instructions[i + 1] - '0';
4242+ const digit = instructions[i + 1] - '0';
43434444 // This 'switch' statement contains the actual work done
4545 // at runtime. At first, this doesn't seem exciting...
···4646 var nums = [_:0]u32{ 1, 2, 3, 4, 5, 6 };
47474848 // And here's a zero-terminated many-item pointer:
4949- var ptr: [*:0]u32 = &nums;
4949+ const ptr: [*:0]u32 = &nums;
50505151 // For fun, let's replace the value at position 3 with the
5252 // sentinel value 0. This seems kind of naughty.
···52525353pub fn main() !void {
5454 // pretend this was defined by reading in user input
5555- var arr: []const f64 = &[_]f64{ 0.3, 0.2, 0.1, 0.1, 0.4 };
5555+ const arr: []const f64 = &[_]f64{ 0.3, 0.2, 0.1, 0.1, 0.4 };
56565757 // initialize the allocator
5858 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
···6464 const allocator = arena.allocator();
65656666 // allocate memory for this array
6767- var avg: []f64 = ???;
6767+ const avg: []f64 = ???;
68686969 runningAverage(arr, avg);
7070 std.debug.print("Running Average: ", .{});
+4-4
patches/patches/025_errors5.patch
···11---- exercises/025_errors5.zig 2023-10-03 22:15:22.122241138 +0200
22-+++ answers/025_errors5.zig 2023-10-05 20:04:06.952764946 +0200
11+--- exercises/025_errors5.zig 2023-11-21 14:22:48.159250165 +0100
22++++ answers/025_errors5.zig 2023-11-21 14:25:01.338277886 +0100
33@@ -26,7 +26,7 @@
44 // This function needs to return any error which might come back from detect().
55 // Please use a "try" statement rather than a "catch".
66 //
77-- var x = detect(n);
88-+ var x = try detect(n);
77+- const x = detect(n);
88++ const x = try detect(n);
991010 return x + 5;
1111 }
+2-2
patches/patches/075_quiz8.patch
···11---- exercises/075_quiz8.zig 2023-10-03 22:15:22.125574535 +0200
22-+++ answers/075_quiz8.zig 2023-10-05 20:04:07.182769252 +0200
11+--- exercises/075_quiz8.zig 2023-11-21 14:48:15.440702720 +0100
22++++ answers/075_quiz8.zig 2023-11-21 14:50:23.453311616 +0100
33@@ -49,7 +49,11 @@
44 //
55 // Please fill in the body of this function!