Builtin

to_bool

to_bool(a) to_bool(a, default_if_empty_string)

Returns the value of a converted to a boolean.

If a is a string and is "" then default_if_empty_string, a bool, is returned instead.

For numbers and times, 0=false and 1=true.

For strings, "false"=false and "true"=true.

Examples

int
to_bool(1)
true

float
to_bool(0.0)
false

str
to_bool("true")
true

str with default
to_bool("", true)
true