跳转至主要内容
CloudStudio

ToBoolean

The ToBoolean function converts a value of any type to boolean.

Definition

ToBoolean(valor)

参数

名称说明Data type
valorValue to convert to boolean. If the value is numeric, it will be converted to false when the value is zero, and to true in any other case. If the value is a string, it will be converted to false when the text is 'false' or '0', and to true when the text is 'true' or '1'. The function will produce an error in any other case. If the value is already boolean, the same value is returned.any

示例

Numeric value conversion

In the following example, 'false' should be displayed if the received value is zero and 'true' if the received value is not zero. 此示例 uses the If function for the comparison; for more information about this function go 此处.

ToBoolean(125)

The result of this ex按下ion is true (boolean).

String value conversion

ToBoolean('0')

The result is false (bool).

最后更新于

本页内容