velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@alaska.net>
Subject Re: [FAQ] How do you check for null?
Date Fri, 03 Dec 2004 19:42:52 GMT
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.

---------------------------------------------------------------------
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