lua-users home
lua-l archive

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


No problem Virgil, knew what you meant and feel like a dodo for looking at assignment (which is what I was trying to achieve) and table construction, which is what I got..

Thanks for the clarification,

-Marc

At 10:47 10/13/2003, Virgil Smith wrote:
First, an apology.  I sent a reply intended to be directly to the author to
the list, it started with an abrupt RTFM, and in a moment of distraction I
"twitch" sent it before toning down the "RTFM" statement or changing the
address.  As I pointed out the exact section of the manual (2.5.6 Table
Constructors in the 5.0 manual) this was actually a very targeted and useful
response.

I did not intend the "RTFM" comment to be offensive, but rather lighthearted
and understanding that sometimes we all make simple mistakes or ask
questions about what is right in front of us.  So, please forgive my very
poor "delivery" (both in phrasing and addressing).

----
That said, Table Construction uses a much richer syntax than that of
multiple assignment.  Information on this can be found in section 2.5.6 of
the 5.0 manual.  The more tricky bits to keep in mind when reading this
information is that numerical indexes <can> be omitted and that explicit
indicies are assumed to be simple strings unless wrapped in []'s in which
case they will be evaluated exactly.




-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Marc Nijdam
Sent: Monday, October 13, 2003 12:24 PM
To: lua@bazar2.conectiva.com.br
Subject: assignment syntax in tables


Hi,

according to the reference manual multi-assignment is possible, eg,

x, y = 1, 2;

Does this apply within tables as well? eg,

table = {
        x, y = 1, 2;
}

Running this through lua and printing the table gives me

2 = 2
y = 1

which is not what I expected... Am I misunderstanding something or is the
only way to do this to declare the table

table = {};

and then place into it

table.x, table.y = 1, 2;

which does do the right thing, but is not what I was trying to do

-Marc