Railo likes to work with nulls

Railo likes to work with nulls

Posted by Luis Majano
Apr 09, 2009 00:00:00 UTC
I just found out about two nice functions in railo:

  • isNull()
  • nullValue()

Finally, a way to interact with java nulls easily. So all you do to create null values is do

if ( isNull( CacheManager.get('key') ) ){

writeoutput("object is not found in cache")


What if you need a null value?

cacheMap['luis'] = nullValue()

Two very simple functions, but they sure make life so so so much easier when integrating with java. This to me are my favorite two new functions.



Yeah, considering the fact that nulls are supported by OpenDB and Railo it looks rather strange that CF is still behind with this. It is so basic requirement.

Brad Wood

I dunno-- while those functions ARE cool, I don't know if I'm convinced that CFML needs NULLs. Not coming from a Java background originally, I've rarely had the need for them in a dynamic language like CF. Languages like Java require all vars to be declared at compile time so it makes more sense to have an un-initialized object laying around with a NULL value. But in CFML, if I don't want the object, I just don't create it. I guess it's just personal coding style, but I'd rather make a function have optional parameters and check for their existence than to always expect them and then test them to see what they are. And on the cache manager example, I really the lookup method that simply returns a Boolean like ColdBox's cache manager does. Thoughts?

Luis Majano


The purpose for the null functions are when you are interacting with java. Java nulls are part of the language, and since CF is built on Java, having the ability to interact with null values or create them in a non-hackable manner are refreshing.

Site Updates

Entry Comments


Entries Search