coerce.to-boolean

coerce.to-boolean attempts to coerce an unknown datum to a Boolean type.

Function category: Coercion

Syntax

coerce.to-boolean(arg1)

Arguments

Description

arg1

Any datum.

Example

Example 1: Boolean string to Boolean - true

If we have a function that is give a string value "true", this function returns a Boolean value true.

# Coerce "true" to true
coerce.to-boolean("true")
# Returns true

Example 2: Boolean string to Boolean - false

If we have a function that is give a string value "false", this function returns a Boolean value false.

# Coerce "false" to false
coerce.to-boolean("false")
# Returns false

Example 3: Any other string

If we have a function that has a string that is neither "true" and "false" this function returns null.

# Coerce a non-Boolean value
coerce.to-boolean("test")
# Returns null