boolean
Casts an object to a boolean.
Syntax
-
boolean(X)
-
X
is any object
-
Description
If X
is any object, boolean(X)
is a boolean with a value that depends on X
, according to the following rules:
-
If
X
is a number, thenboolean(X)
istrue
iffX
is not (exactly) zero. -
If
X
is a string, then:-
If
X
converted to lower case is"true"
, thenboolean(X)
istrue
. -
If
X
converted to lower case is"false"
, thenboolean(X)
isfalse
. -
Otherwise, an error is raised.
-
-
If
X
is a container which is not a string, thenboolean(X)
istrue
iff#X > 0
. -
If
X
is a null object, thenboolean(X)
isfalse
. -
If
X
is a success indication, thenboolean(X)
istrue
. -
If
X
is a boolean, thenboolean(X)
isX
. -
If
X
is a binary data object, thenboolean(X)
istrue
iffX
contains at least one non-zero byte. -
If none of the above points apply, then
boolean(X)
istrue
.