Type: Feature Request
Status: Open (View Workflow)
Affects Version/s: None
Fix Version/s: None
This table outlines a suggestion of how the following values would behave when cast to booleans:
|Number||false if 0, otherwise true|
|String||false if "", "false", or "no"; otherwise true.|
|Array||false if empty, otherwise true|
|Struct||false if empty, otherwise true|
This would allow for the full ternary version of the Elvis operator (Assuming full null support):
It would also simplify checking for the contents of structs and arrays:
I think these changes might be somewhat straightforward and mostly affect the Caster class, but most importantly:
- Do we want this in CFML?
- Would this have serious implications in backwards compatibility?
Other things to consider that are similar to Groovy would be Java Map, List and Iterator classes. True if not empty, or hasNext() is true.