[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Just curious: Why is tonumber(nil) not 0?
- From: Henk Boom <henk@...>
- Date: Mon, 27 Apr 2009 10:21:34 -0400
2009/4/27 Evan DeMond <email@example.com>:
> Just to look at things another way, then, is it troubling that tonumber()
> isn't guaranteed to return a number?
> Not saying that I think that nil should be convertible to a numeric value,
> but I'd like to hear others' thoughts on that point. =)
If it were guaranteed to return a number there would be no way to
signal failure. You would need to have an isnumeric() to go along with
it, and then you might find that 'isnumeric(x) and tonumber(x)' would
become a common idiom =).