% API
Builtins
Bool
Bool.parse
Bool.parse : func(text: Text, remainder: &Text? = none -> Bool?)
Converts a text representation of a boolean value into a boolean. Acceptable boolean values are case-insensitive variations of yes/no, y/n, true/false, on/off.
| Argument | Type | Description | Default |
|---|---|---|---|
| text | Text |
The string containing the boolean value. | - |
| remainder | &Text? |
If non-none, this argument will be set to the remainder of the text after the matching part. If none, parsing will only succeed if the entire text matches. | none |
Return: yes if the string matches a recognized truthy boolean value; otherwise return no.
Example:
assert Bool.parse("yes") == yes
assert Bool.parse("no") == no
assert Bool.parse("???") == none
assert Bool.parse("yesJUNK") == none
remainder : Text
assert Bool.parse("yesJUNK", &remainder) == yes
assert remainder == "JUNK"
1 % API3 # Builtins5 # Bool6 ## Bool.parse9 Bool.parse : func(text: Text, remainder: &Text? = none -> Bool?)10 ```12 Converts a text representation of a boolean value into a boolean. Acceptable boolean values are case-insensitive variations of `yes`/`no`, `y`/`n`, `true`/`false`, `on`/`off`.14 Argument | Type | Description | Default15 ---------|------|-------------|---------17 remainder | `&Text?` | If non-none, this argument will be set to the remainder of the text after the matching part. If none, parsing will only succeed if the entire text matches. | `none`19 **Return:** `yes` if the string matches a recognized truthy boolean value; otherwise return `no`.22 **Example:**24 assert Bool.parse("yes") == yes25 assert Bool.parse("no") == no26 assert Bool.parse("???") == none28 assert Bool.parse("yesJUNK") == none29 remainder : Text30 assert Bool.parse("yesJUNK", &remainder) == yes31 assert remainder == "JUNK"33 ```