[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "Dereferencing" a key of a table
- From: Choonster TheMage <choonster.2010@...>
- Date: Wed, 18 Jul 2012 13:45:16 +1000
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