mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-06-08 07:50:00 +00:00
fixup! Add another defer exercise
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
--- exercises/028_defer2.zig 2023-10-03 22:15:22.122241138 +0200
|
||||
+++ answers/028_defer2.zig 2023-10-05 20:04:06.966098530 +0200
|
||||
@@ -18,7 +18,7 @@
|
||||
--- exercises/028_defer2.zig 2026-06-02 06:08:12.713672612 +0200
|
||||
+++ answers/028_defer2.zig 2026-06-02 06:08:43.262234023 +0200
|
||||
@@ -20,7 +20,7 @@
|
||||
fn printAnimal(animal: u8) void {
|
||||
std.debug.print("(", .{});
|
||||
|
||||
@@ -9,3 +9,15 @@
|
||||
|
||||
if (animal == 'g') {
|
||||
std.debug.print("Goat", .{});
|
||||
@@ -51,9 +51,9 @@
|
||||
|
||||
// Try reordering the statements to get the answer 42
|
||||
{
|
||||
- defer x = x / 10;
|
||||
- defer x = x + 11;
|
||||
defer x = x * 2;
|
||||
+ defer x = x + 11;
|
||||
+ defer x = x / 10;
|
||||
}
|
||||
|
||||
return x;
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
--- exercises/116_defer3.zig 2026-05-31 22:29:56.189323732 +0200
|
||||
+++ answers/116_defer3.zig 2026-05-31 22:30:17.749186667 +0200
|
||||
@@ -7,9 +7,9 @@
|
||||
var x: u32 = 100;
|
||||
{
|
||||
// Try reordering the statements to get the answer 42
|
||||
- defer x = x / 10;
|
||||
- defer x = x + 11;
|
||||
defer x = x * 2;
|
||||
+ defer x = x + 11;
|
||||
+ defer x = x / 10;
|
||||
|
||||
// It might seem silly in this example, but it's important to know when
|
||||
// deinitializing containers whose elements need to be deinitialized first.
|
||||
Reference in New Issue
Block a user