lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Apr 27, 2009 at 10:21 AM, Henk Boom <henk@henk.ca> wrote:
2009/4/27 Evan DeMond <evan.demond@gmail.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 =).

   Henk

Yep, and this was one of those times I recognized the obvious immediately after hitting "Send," too. Sorry for the noise. =)