Skip to content

Conversion

tobool

Property Details
Function tobool(value)
Description Converts value to a boolean. Numbers, characters, and strings follow specific truthiness rules.
Parameters value (number, char, string, or bool) – The value to convert.
Return Type bool
Conversion Rules Numbers: 0false, nonzero → true
Chars: Always true
Strings: "true"true, "false"false, empty → false, non-empty → true
Booleans: Returned as-is
Errors Throws an exception if value is an unsupported type.
Example tobool(0)false
tobool(42)true
tobool('A')true
tobool("")false
tobool("true")true
tobool("false")false

tochar

Property Details
Function tochar(value)
Description Converts value to a character if possible. Different types follow specific conversion rules.
Parameters value (number, char, string, or bool) – The value to convert.
Return Type char
Conversion Rules Numbers: Cast to char if within valid range.
Chars: Returned as-is.
Strings: Must be exactly one character long.
Booleans: true'T', false'F'
Errors Throws an exception if value is an unsupported type, a number outside the valid character range, or a string longer than one character.
Example tochar(65)'A'
tochar('Z')'Z'
tochar("B")'B'
tochar(true)'T'
tochar(false)'F'

tolist

Property Details
Function tolist(value)
Description Converts a string into a list of characters. Each character in the string becomes an individual element in the list.
Parameters value (string) – The string to convert into a list of characters.
Return Type list (of char)
Errors Throws an exception if value is not a string.
Example tolist("abc")['a', 'b', 'c']
tolist("7")['7']

tonum

Property Details
Function tonum(value)
Description Converts a value into a number. Strings are parsed as numbers, booleans convert to 1 (true) or 0 (false), and characters are converted to their numeric values.
Parameters value (char, string, boolean, or number) – The value to convert into a number.
Return Type number
Errors Throws an exception if value is a string that cannot be converted to a number or if value is of an unsupported type.
Example tonum('5')5
tonum("42.3")42.3
tonum(true)1
tonum(false)0

tostr

Property Details
Function tostr(value)
Description Converts a value into a string representation.
Parameters value (any type) – The value to convert into a string.
Return Type string
Errors None (all values have a string representation).
Example tostr(42)"42"
tostr(true)"true"
tostr('A')"A"