[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Expression statements
- From: David Manura <dm.lua@...>
- Date: Mon, 16 Aug 2010 19:02:01 -0400
On Mon, Aug 16, 2010 at 2:27 PM, Wesley Smith <wesley.hoke@gmail.com> wrote:
> On Mon, Aug 16, 2010 at 8:17 PM, Peyman <peiman_3009@yahoo.com> wrote:
>>... in many langs 0 and null string have false value.
>
> In my experience these other languages are C and C++. Java requires
> explicit x == null for objets for example. Ruby is similar to Lua in
> this respect as well. Basically what I'm getting at is that the
> majority of languages are not this way. I used to think the same
> thing as you, but in the end my thinking was warped by the all
> pervasiveness of C and C++.
The Lua behavior of treating "" and 0 as true make the `a and b or c`
approximation of the ternary operator [1] more likely to work. On the
other hand, I find quite a few occasions where it doesn't work and I
would prefer a real ternary operator.
[1] http://lua-users.org/wiki/TernaryOperator