lua-users home
lua-l archive

Re: At sign ``@'' in key

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


On Wed, Dec 19, 2012 at 5:26 PM, Grizzly Bear <6grizzlybear@gmail.com> wrote:
> Hi,
>
> I'd really want to have the at sign ``@'' in the key of a table, e.g.,
> tab["var@addr"] = 1.
>
> But I haven't been able to do
> tab.var@addr = 1.
>
> The error message was
> stdin:1: '=' expected near '@'
>
> I'm using Lua 5.1.5. Any suggestions?
>
> Thanks.
> Wei
"Doctor, it hurts when I do this."
"Then don't do that."
If you want to use keys that have characters that aren't valid in
identifiers, you have to use the [] syntax.
/s/ Adam

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