lua-users home
lua-l archive

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


On Wed, Jul 18, 2012 at 1:30 PM,  <meino.cramer@gmx.de> wrote:
> Hi,
>
> I have the following code via lua -i
>
>     a={}
>     a.bob="alice"
>     keyname="bob"
>
>     =a.keyname
>     nil
>
> Is there a way to access the key of an table, which name is store in
> another variable?
>
> Thank you very much in advance for any help!
>
> Best regards,
> mcc
>
>

a.keyname accesses the string "keyname", a[keyname] accesses the value
of keyname.

http://www.lua.org/manual/5.1/manual.html#2.3