On Null

I'm finally doing a lot of work with CF 9's ORM and I'm finding that dealing with null values in CFML can be quite a pain, especially when working with relationships. One thing that comes up quite a bit is iterating over child collections. ColdFusion goes out of it's way to shield developers from null values, yet when an entity has an empty collection ColdFusion returns a null. (Long time user of CFML would likely expect an empty array here, similar to how <cfquery> returns and empty string for null values, but this is not the case.) This means I end up doing something like this quite a bit:


Dan G. Switzer, II's Gravatar In JavaScript, you could do:

parent.getChildren() || []

Instead of:

I wonder if that works in CF9?
# Posted By Dan G. Switzer, II | 2/26/11 3:35 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.