I'm against changing this.

I've recently encountered this issue in PHP, where 0, false, empty
string and null all fail an if condition.  I was testing to see if an
object was null, but it was 0 so it failed.  (when it should have
passed).  Took me a while to figure out why my if condition was
failing.

If you have booleans and ints but no nulls having 0 == false makes
sense, they are two separate things.  But when you also have nulls, I
think that having a "test for null" be the same as "test for 0" is a
little confusing.

WILL


On 8/27/06, Henning P. Schmiedehausen <[EMAIL PROTECTED]> wrote:
Just stumbled over that:

--- cut ---

#set ($a = 0)
#set ($b = 1)

#set ($c = $a and $b)
#set ($d = $a or $b)

A: $a
B: $b
C: $c
D: $d

Rendering this template gives a bit of a surprising result:

A: 0
B: 1
C: true
D: true

While the behaviour is obvious (anything not-null is true in Velocity
expressions), it is still sort of a "gotcha". Personally I'd like to
see this behaviour changed (number '0' or the empty String '' get
converted to "false") because then it would match the expression
system of well known languages like perl or php(?).

Any opinions on that?

        Best regards
                Henning

--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
[EMAIL PROTECTED]        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

Social behaviour: Bavarians can be extremely egalitarian and folksy.
                                    -- http://en.wikipedia.org/wiki/Bavaria
Most Franconians do not like to be called Bavarians.
                                    -- http://en.wikipedia.org/wiki/Franconia

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Forio Business Simulations

Will Glass-Husain
[EMAIL PROTECTED]
www.forio.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to