[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to cast a table knowing its name?
- From: Jilani Khaldi <jilani.khaldi1@...>
- Date: Fri, 24 Sep 2004 22:10:12 +0200
Adam D. Moss wrote:
Welll begore asking I have already tried many ways. Just to wonder why
when I set:
Jilani Khaldi wrote:
how to write in Lua something like this:
and have a new table (newtab) which has all the data of the table
Write a function called 'tab' ('table' is already taken
by the lua's standard optional table library) which uses
the string of its first parameter as an index into the
globals table. That'll fetch a table with that name, if
it exists. Then return a new table with a shallow copy
of the table you just fetched (or simply return that
table itself, which will return a reference instead of
a copy -- that might be okay or desirable depending on
what you want to do with the returned table).
If you want more detail then ask. :) (I know that some
people on this list will gleefully write exactly the
function that anyone asks for if it's half-interesting
to do so, but writing such relatively simple things
yourself is a perfect way to learn Lua!).
lg = globals()
I get an error. Do I have to import some library to use globals()?
M€TA (Manuale Economico & Tecnico dell'Architetto)