improved i/o explanation for exc. 26

This commit is contained in:
Chris Boesch 2025-12-28 02:01:19 +01:00
parent b33fd5a744
commit 8e30debc6a
No known key found for this signature in database
GPG Key ID: 8712DF4D3E364668

View File

@ -5,7 +5,7 @@
// //
const std = @import("std"); const std = @import("std");
// Instance for input/output, we'll learn how to create them later. // Instance for input/output operations, we'll learn how to create them later.
const io = std.Options.debug_io; const io = std.Options.debug_io;
// Take note that this main() definition now returns "!void" rather // Take note that this main() definition now returns "!void" rather
@ -18,8 +18,9 @@ const io = std.Options.debug_io;
// https://ziglang.org/documentation/master/#Inferred-Error-Sets // https://ziglang.org/documentation/master/#Inferred-Error-Sets
// //
pub fn main() !void { pub fn main() !void {
// We get a Writer interface for Standard Out so we can print() to it. // We get a Writer for Standard Out...
var stdout_writer = std.Io.File.stdout().writer(io, &.{}); var stdout_writer = std.Io.File.stdout().writer(io, &.{});
// ...and extract its interface so we can print() to it.
const stdout = &stdout_writer.interface; const stdout = &stdout_writer.interface;
// Unlike std.debug.print(), the Standard Out writer can fail // Unlike std.debug.print(), the Standard Out writer can fail