types.Bool.tochar
Method on every
boolConverts the bool to a one-character string, treating it as a character code.
Return value
A string of length 1: chr(1) for true, chr(0) (a NUL byte) for false. Neither is printable - true's casts to the same character code as (1).tochar(), a control character, not a letter or digit.
Notes
Takes no arguments. See types.Integer.tochar for the general (char)-cast mechanism this shares.
Example
// true.tochar() is chr(1), a control character - print its code, not the raw byte.
let c = true.tochar()
println("c.len() =", c.len())
println("c[0] =", c[0])
println("false.tochar()[0] =", false.tochar()[0])Output:
c.len() = 1
c[0] = 1
false.tochar()[0] = 0See also
tochar | Converts the integer to a one-character string, treating it as a character code. |
tochar | Converts the float to a one-character string, treating it as a character code. |
tointeger | Converts the bool to an integer. |
| bool | class index |