lua-users home
lua-l archive

Re: digit strings as table indexes

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


Sam Roberts wrote:
On Thu, Jan 25, 2007 at 10:22:09AM -0600, Jimmie Houchin wrote:
Would it be better, even if seemingly uglier (to me) to use
'ssn123-45-6789' instead of simply '123-45-6789'
which would make the digit string into a legitimate Lua name.
Actually, it wouldn't, ssn123-45-6789 is not a lua "name":
% lua
Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
ssn123-45-6789 = 3
stdin:1: `=' expected near `-'
ssn123 = 3
print(ssn123-45-6789)
-6831
Wow, I just got bit by another assumption on my part. Oops. :)
Obviously I wasn't thinking. Nor have I attempted such. I would definitely have to remove the dashes to make such valid.
Thanks for pointing that out to me.
It helps in training my mind to spot thinking errors.
Jimmie

AltStyle によって変換されたページ (->オリジナル) /