def nullString = "String is NOT null"
def check = (nullString != null) ? nullString : "String is null"
def check2 = nullString ? nullString : "String is null"
def check3 = nullString ?: "String is null"
println check
println check2
println check3
Tell me if I'm wrong, but these three ternary statements above should all do the same thing, namely print out "String is NOT null" if nulString is not null. If nullString is null, print out "String is null".
And I think you all agree, if I initialze a variable like nullString = "" it is not null. Just because "" is not null.
But when testing the code above with nullString = "" only the first one prints out "String is NOT null". The other two interpret "" as null. Why is that?
(Sorry for my english, I hope you understand what I'm trying to say)