mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-04-03 00:14:53 +00:00
21 lines
797 B
Diff
21 lines
797 B
Diff
--- exercises/106_files.zig 2025-12-28 20:38:53.005504479 +0100
|
|
+++ answers/106_files.zig 2025-12-28 20:37:42.742154100 +0100
|
|
@@ -39,7 +39,7 @@
|
|
// by doing nothing
|
|
//
|
|
// we want to catch error.PathAlreadyExists and do nothing
|
|
- ??? => {},
|
|
+ error.PathAlreadyExists => {},
|
|
// if there's any other unexpected error we just propagate it through
|
|
else => return e,
|
|
};
|
|
@@ -59,7 +59,7 @@
|
|
// but here we are not yet done writing to the file
|
|
// if only there were a keyword in Zig that
|
|
// allowed you to "defer" code execution to the end of the scope...
|
|
- file.close(io);
|
|
+ defer file.close(io);
|
|
|
|
// you are not allowed to move these lines above the file closing line!
|
|
var file_writer = file.writer(io, &.{});
|