lua-users home
lua-l archive

question about table elements

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


Lua list,
I'm having a difficult time accessing table elements and I would
appreciate some help. The code below is test code but it behaves the
same way that my larger program does.
-- begin example --
t1 = {
 ["a"] = 1,
 ["b"] = 2,
 ["c"] = 3,
}
t2 = {
 ["x"] = "a",
}
tmp = t2.x
print(tmp) --> a
print(t1.tmp) --> nil
-- end example --
How could I achieve the goal of using the value stored in 't2.x' to
access 't1.a'? I suspect I'm overlooking something simple and would
appreciate any advice you may offer.
Ryan

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