Skip to content

Instance Method

ask(_:isSecure:)

Requests input from the console after displaying a prompt.
func ask(_ prompt: ConsoleText, isSecure: Bool = false) -> String

Parameters

prompt

Text to display before asking for input.

isSecure

See input(isSecure:)

Return Value

Input String. entered in response to the prompt.

Discussion

let answer = console.ask("How are you doing?")
console.output("You said: " + answer.consoleText())

Input will be read until the first newline. See input(isSecure:). The above code outputs:

How are you doing?
> great!
You said: great!