XDPXI's Documentation
Builtin Functions

Type Functions

Required version: Sponge >=1.0.0

Type Checking

typeof

Returns the type of a value as a string:

print(typeof(42));         # "number"
print(typeof(3.14));       # "float"
print(typeof("hello"));    # "string"
print(typeof(true));       # "boolean"
print(typeof([1, 2]));     # "array"
print(typeof({a: 1}));     # "dict"
print(typeof(null));       # "null"

Type Predicates

print(is_number(42));      # true
print(is_number(3.14));    # true
print(is_string("hi"));    # true
print(is_array([1, 2]));   # true
print(is_dict({a: 1}));    # true

Type Conversion

Most conversions happen implicitly, but you can use operations to convert:

let num = 42;
let str = concat(num, " is the answer");  # Convert to string implicitly