SLUDGE

Treating Variables as Booleans


You can treat all variables as boolean values... that is, you can say:

if (myVariable)

...no matter what data type is actually in the variable. Here's how they're all treated.

Undefined:

Always equates to FALSE..

Numbers:

Equates to FALSE if it contains the value 0; TRUE for everything else.

Strings:

Always equates to TRUE.

File handles:

Always equates to TRUE.

Object types:

Always equates to TRUE.

Stacks:

Equates to FALSE if the stack is empty; TRUE for everything else.

Function handles:

Always equates to TRUE.

Animations:

Always equates to TRUE.

Costumes:

Always equates to TRUE.

See also:

Variable Operations