Convert to truth value

Syntax

	$value.toBoolean()

Description

Converts a value to a boolean. This conversion usually happens automatically when a value is used in a context where a boolean is expected, e.g. in a condition like $value.ifElse(true, false). The explicit conversion may be necessary if a boolean value is to be stored in an attribute of a model element.

The result is calculated as follows:

  • false, if value is false, null, or empty,
  • true for all other cases

Parameter

Name Type Description Mandatory Default
value Number/string/boolean/Business object/set A value to be converted to a boolean. yes

Return value

Type: Boolean

The converted value.

Examples

Boolean value

	false.toBoolean()

Output: false

Non-boolean value

	date(2021, 5, 8).toBoolean()

Output: true

Since the date value is neither null, empty, nor false, this results in true.

Null

	null.toBoolean()

Output: false

Empty list

	list().toBoolean()

Output: false

Since the list is empty, this results in false.