velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Christian <si...@stoutstick.com>
Subject Re: [FAQ] How do you check for null?
Date Mon, 06 Dec 2004 11:48:32 GMT
Mike Kienenberger wrote:
> Simon Christian <simon@stoutstick.com> wrote:
> 
>>Mike Kienenberger wrote:
>>
>>>So you really either need to use the tool or do this:
>>>
>>>#if ((! $car.fuel) && ("$!car.fuel" == ""))
>>>
>>>-Mike
>>>
>>
>>No the first bit isn't necessary, just #if( "$!car.fuel" == "" ) covers 
>>the eventualities when testing for null.
> 
> 
> That's not true.
> 
> car.fuel = "" is not the same as car.fuel = null, yet both pass the 
> condition.
> 
> Unless the template designer knows the underlying type of the java object, 
> the only safe solution is to check for "(null or false) and (null or 
> empty-string)" => if true, must be null.
> 

Sorry Mike you're absolutely right, I was only considering the 
non-exhaustive set of cases I usually come across and blinded to the 
other possibilities.

Humbly,

- simon

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message