userInput

The userInput function provides a means to accessing a single value from the user. Each invocation outputs a provided statement/question and takes an entire line of input. The result is then converted to the requested type; default is a string.

auto name = userInput("What is your name");
//or
string name;
userInput("What is your name", name);
  1. T userInput(string question = "")
    T
    userInput
    (
    T = string
    )
    (
    string question = ""
    )
  2. void userInput(string question, ref T result)

Return Value

Type: T

User response as type T.

Where type is bool:

true on "ok", "continue", and if the response starts with 'y' or 'Y'.

false on all other input, include no response (will not throw).

Throws

NoInputException if the user does not enter anything. ConvError when the string could not be converted to the desired type.

Meta