Q:

How to compare for null in groovy correctly?

edit: Stupid. The problem was that I got a string with value 'null'

How to compare for null in groovy correctly?
I've got the following script
println "row6: " + row[6]

if(row[6] == null) {
  println "if"
}
  else {
  println "else"
}

When I run it with a row where the specified field is null this is the output:
row6: null
else

The Groovy Docs say a == null will work, while a.is(null) will not.
So how do I compare for null in groovy the right way?
P.S. I saw The SO-Thread: comparing-null-and-number-in-groovy. It says that null is handled as a number, but this would still mean a == comparision should work when the value is null.

A:

This code prints if:
def row = []
row[6] = null
println "row6: " + row[6]

if(row[6] == null) {
  println "if"
} else {
  println "else"
}

Are you sure that row[6] is null?

