Railo - acting on null as a string

18 June 2014

When you act on a variable as a string but instead is null, it's treated as an empty string.

Take concatenation:

   x = null;   echo("X = " & x);              // "X ="   echo("X = #x#");               // "X ="   echo("Null = #null#");         // "Null ="   echo(expandPath(null));        // "/path/to/current/directory"   echo(repeatString(null, 100)); // 100 empty strings!   echo(x.len());                 // Error: can't call method [len] on object, object is null   echo("#x#".len());             // Error: can't call method [len] on object, object is null - I expected this to work   echo((x & "").len());          // 0  

expandPath(null) caught me out recently!