boolean
Casts an object to a boolean.
Syntax
-
boolean(X)-
Xis 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
Xis a number, thenboolean(X)istrueiffXis not (exactly) zero. -
If
Xis a string, then:-
If
Xconverted to lower case is"true", thenboolean(X)istrue. -
If
Xconverted to lower case is"false", thenboolean(X)isfalse. -
Otherwise, an error is raised.
-
-
If
Xis a container which is not a string, thenboolean(X)istrueiff#X > 0. -
If
Xis a null object, thenboolean(X)isfalse. -
If
Xis a success indication, thenboolean(X)istrue. -
If
Xis a boolean, thenboolean(X)isX. -
If
Xis a binary data object, thenboolean(X)istrueiffXcontains at least one non-zero byte. -
If none of the above points apply, then
boolean(X)istrue.