Type conversion utilities.
use "conv"Converts any value to a string.
s = conv.to_s(42) # "42"
s = conv.to_s(3.14) # "3.14"
s = conv.to_s(true) # "true"Converts a value to an integer.
n = conv.to_i("42") # 42
n = conv.to_i(3.9) # 3
n = conv.to_i(true) # 1
n = conv.to_i(false) # 0Panics if the string is not a valid integer.
Converts a value to a float.
f = conv.to_f("3.14") # 3.14
f = conv.to_f(42) # 42.0Panics if the string is not a valid number.
Converts a value to a boolean.
conv.to_bool(1) # true
conv.to_bool(0) # false
conv.to_bool("") # false
conv.to_bool("hello") # true
conv.to_bool("false") # false
conv.to_bool(nil) # falseRules: false, 0, 0.0, "", "false", and nil are falsy. Everything else is truthy.
Parses a string as an integer with a given base.
conv.parse_int("ff", 16) # 255
conv.parse_int("1010", 2) # 10
conv.parse_int("77", 8) # 63
conv.parse_int("42", 10) # 42Panics if the string is not valid for the given base.