Skip to main content

Functions: Type

Kahuna provides functions to check the type of a variable and to cast values between supported types, helping developers write safer and more predictable logic.

Type Checking Functions

FunctionDescriptionExample
is_null(x)Returns true if x is nullis_null(null)true
is_bool(x) / is_boolean(x)Returns true if x is a booleanis_bool(true)true
is_int(x) / is_integer(x) / is_long(x)Returns true if x is an integeris_int(42)true
is_float(x) / is_double(x)Returns true if x is a floating-point numberis_double(42.5)true
is_str(x) / is_string(x)Returns true if x is a stringis_string("hello")true
is_array(x)Returns true if x is an arrayis_array([1, 2, 3])true

Type Casting Functions

FunctionDescriptionExample
to_bool(x) / to_boolean(x)Casts x to a booleanto_bool("true")true
to_int(x) / to_integer(x) / to_long(x) / to_number(x)Casts x to an integerto_int("42")42
to_float(x) / to_double(x)Casts x to a floating-point numberto_double("42.5")42.5
to_str(x) / to_string(x)Converts x to a stringto_string(99)"99"

These functions are especially useful in dynamic scripting scenarios, when working with user input, or reading heterogeneous data from the key/value store.