Signature
bool to_bool(String s, bool fallback = false)
Parameters
s : string to parse
fallback : value returned when
s is empty or not a recognized boolean tokenreturn value : parsed bool, or
fallback.Parses a trimmed, case-insensitive boolean string.
Truthy tokens are "1", "true", "yes", and "on". Falsey tokens are "0", "false", "no", and "off". Empty or unrecognized strings return the fallback.
Example
print(to_bool("yes") ? "true\n" : "false\n");
Output
true