toBoolean

Converts a value to a boolean. A missing value or any value whose boolean coercion is false (false, 0, empty string, null) becomes false; everything else becomes true.

toBoolean(value) → returns boolean

This function requires RustCFML.  Not supported on Lucee, Adobe ColdFusion, etc.

Argument Reference

value any

The value to convert.

Examples
Sample code invoking the toBoolean function

Various values coerced to booleans.

writeDump(toBoolean(1));
writeDump(toBoolean(""));
writeDump(toBoolean("off"));

Expected Result: true false true

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub