Hello world/Standard error: Difference between revisions

→‎{{header|Zig}}: Split comment into separate example, annotate working versions.
imported>Brie
(Add Nu)
(→‎{{header|Zig}}: Split comment into separate example, annotate working versions.)
Line 1,288:
 
=={{header|Zig}}==
'''Works with:''' 0.10.x, 0.11.x, 0.12.0-dev.1357+10d03acdb
 
Variant with error handling:
<syntaxhighlight lang="zig">const std = @import("std");
 
pub fn main() !void {
pub fn main() std.fs.File.WriteError!void {
try std.io.getStdErr().writer().writeAll("Goodbye, World!\n");
const stderr = std.io.getStdErr();
// debug messages are also printed to stderr
 
//std.debug.print("Goodbye, World!\n");
try std.io.getStdErr().writer()stderr.writeAll("Goodbye, World!\n");
}</syntaxhighlight>
'''Works with:''' 0.10.x, 0.11.x, 0.12.0-dev.1357+10d03acdb
 
Variant with no error handling (useful when debugging):
<syntaxhighlight lang="zig">const std = @import("std");
 
pub fn main() !void {
// Silently returns if writing to stderr fails.
//std.debug.print("Goodbye, World!\n", .{});
}</syntaxhighlight>
 
28

edits