String parsing methods convert string values into numbers or boolean-style numbers.
Invalid input raises a runtime error.
Parses decimal numeric text.
| Item | Description |
|---|---|
| Syntax | `string.parse_num()` |
| Arguments | none |
| Returns | number |
Example:
'123.45'.parse_num(); '-10'.parse_num();
Parses hexadecimal text.
| Item | Description |
|---|---|
| Syntax | `string.parse_hex()` |
| Arguments | none |
| Returns | number |
Example:
'FF'.parse_hex(); // 255 '0x10'.parse_hex(); // 16
Parses binary text.
| Item | Description |
|---|---|
| Syntax | `string.parse_bin()` |
| Arguments | none |
| Returns | number |
Example:
'1010'.parse_bin(); // 10 '0b1010'.parse_bin();
Parses boolean text.
| Item | Description |
|---|---|
| Syntax | `string.parse_bool()` |
| Arguments | none |
| Returns | boolean-style number |
Accepted values are `true`, `false`, `1`, and `0`.
Example:
'true'.parse_bool(); // true '0'.parse_bool(); // false
Previous: String Slice Methods