String module

parse_bool

procedureSource

Reads the next token and reads it as true or false, in either case. The second result is false when the token is anything else or there is none; the token is removed from line anyway.

parse_bool :: (
    line: *string,
    delimiters := DEFAULT_DELIMITERS,
    spaces := DEFAULT_SPACES
) -> (value: bool, success: bool)

Parameters

line: *string
delimiters := DEFAULT_DELIMITERS
spaces := DEFAULT_SPACES

Returns

value: bool
success: bool
Example↗
line := "True rest";
value, ok := parse_bool(*line);
assert(ok && value && line == " rest");

See also