[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Just curious: Why is tonumber(nil) not 0?
- From: Timothy Baldridge <tbaldridge@...>
- Date: Mon, 27 Apr 2009 08:43:02 -0500
Ahhh, the classic argument. Nil and zero are not the same, zero
represents the lack of quantity of something being counted, nil
represents the lack of data. In some areas of computing (such as the
database work I do) this is a major difference. In my mind,
tonumber(nil) should return nil.
Timothy
On Mon, Apr 27, 2009 at 8:32 AM, Mike Crowe <drmikecrowe@gmail.com> wrote:
> Hi folks,
>
> I was briefly caught by doing this test:
>
> if tonumber(something) > 0 then
> ...
> end
>
> with something=nil.
> I'm not advocating a change, but what's the thought-process behind this
> behavior? Wouldn't you consider the numeric value of nil to be 0?
>
> Mike
>
--
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)