Open MordantWastrel opened 3 years ago
You won't be able to use the null coalescing operator (?:
) so we can maintain compatibility with older engines. Additionally, I'd prefer to return null
rather than an empty string.
Maybe something like
return item.keyExists( keys[ 1 ] ) && !isNull( item[ keys[ 1 ] ] ) ? item[ keys[ 1 ] ] : javacast( "null", "" );
I like that better as well! I'll play with it and get a patch in.
FYI, the box.json for CFCollection is pointing to Coldbox 4 and Testbox 2. That's some generous backwards compatibility!
Ha...it is. I've been wanting to modernize this entire module using more of the built-in functional methods in later CFML engines, but it just hasn't happened yet.
I finally got an opportunity to play some with cfcollection a month ago or so and ran into a small issue when dealing with collections that may have null keys. See this example:
Good so far!
But if you try this:
It will throw:
on Collection.cfc : 87 (ID: ??, Type: cfml)
Which is this line:
This works as a workaround:
Do you prefer a different solution or shall I submit that as a PR?