Be careful with ColdFusion 9's isNull

This post is more than 2 years old.

I guess this isn't surprising - but I certainly wasn't expecting it. Check out the following code snippet:

public function renderPanels(string area, any me, any group = "", any helper="") { var panels = getPanels(); if(isNull(paensl)) return; for(var i=1; i<=arrayLen(panels); i++) { if(panels[i].getArea() == arguments.area) {

Notice anything odd? How about that horrible typo on the 3rd line. But what surprised me was that this didn't throw a variable is undefined error. Since the variable didn't exist, it returned true for isNull. Obviously I expect to get nulls from my getPanels() code (a Page object may have panels) but the typo made it always return true.

Again - 100% obvious and expected - but this is the first time I've done this in CF9.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for HERE Technologies. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA