lua-users home
lua-l archive

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


On 20.12.2012 02:26, Grizzly Bear 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?

Put your key into var:
local key="var@addr"
tab[key]=1

or use:
tab[ [[var@addr]] ]=1

Works for me for both Lua 5.1 and 5.2.

Regards,
miko