How do I print a message to the console in EK9?
← Getting Started · Ref: Q871
In Java you write System.out.println(), in Python you write print(). In EK9 the equivalent is:
stdout <- Stdout() stdout.println("your message")
The '<-' creates a local variable called stdout that holds a reference to standard output. Then you call println() on it. This two-step pattern — create the output stream, then write to it — appears in every EK9 program.
You must wrap this inside 'defines module' and 'defines program' blocks. See Q1 for the full structure. Use 'ek9 -h Stdout' for all available output methods.
Example
defines module qa.getting.started.hello.variant defines program PrintMessage() stdout <- Stdout() stdout.println("Welcome to EK9") stdout.println("Programming is fun")
Other ways to ask this
- How do I output text in EK9?
- What is the EK9 equivalent of System.out.println?
- How do I write to stdout in EK9?
Coming from another language?
Java: System.out.println(). Python: print(). Go: fmt.Println(). EK9: Stdout().println().
Keywords: output, print, message, println, text, console, stdout