Console Example
The following is an example of Console. In the example, two pieces of information entered by a user are received and returned to the user through standard output streams.
import std.console.*
main() {
Console.stdOut.write("Please enter information 1: ")
var c = Console.stdIn.readln() //Input: Hello. What day is it today?
var r = c.getOrThrow()
Console.stdOut.writeln("Input information 1: " + r)
Console.stdOut.write("Please enter information 2: ")
c = Console.stdIn.readln() // Input: Hello. What's the date today?
r = c.getOrThrow()
Console.stdOut.writeln("Input information 2: " + r)
return
}
Running result:
Please enter information 1: Hello. What day is it today?
Input information 1: Hello. What day is it today?
Please enter information 2: Hello. What's the date today?
Input information 2: Hello. What's the date today?