Sunday, August 24, 2008

Interesting String behavior in Groovy

I've been writing some Groovy code in the last week. I did something silly that the Java compiler would have caught and scolding me for doing:

def body
// ....
body += someContent
What happened was my body strings were all prefixed with the character string "null." Apparently doing a concatenation on a null String causes "null" to be produced.

I do not claim this to be good or bad - I just think it's interesting.

No comments: