LEARN VOID

Writing to the console

Write one line to standard output and return a separate application status.

console-output.voidDownload source
use console

func main() -> i32:
    if console.stdout.write("Map loaded.\n") is Ok(var written):
        return 0
    return 1
Exit status 0Standard output "Map loaded.\n"

Write one record

use console provides borrowed standard endpoints. Running this main writes a line to stdout. A successful write returns status zero from the application.

Check output errors

A redirected stream may be closed. Check the result of console.stdout.write. An I/O error can include partial progress. The example returns a failure status if the write fails.

Ask about terminal capabilities

Query an endpoint’s capabilities() before relying on colors, cursor movement or keyboard input. Capabilities can differ between stdout and stderr. Use flush() when a prompt must appear before a read.

Continue learning with Error handling · Application entry.