[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: table constructors
- From: virgil@... (Virgil Smith)
- Date: Thu, 14 Aug 2003 11:01:12 -0500
>From what I can tell you are trying to declare/name sub-tables ahead of time
and you don't need to do that...
your code...
temp = {"a", "b"}
temp["a"] = {"a" = 0, "b" = 2}
temp["b"] = {"a" = 1, "b" = 0}
results in a table with the following entries (Key --> Value)
1 --> "a"
2 --> "b"
"a" --> {"a" --> 0, "b" --> 2}
"b" --> {"a" --> 1, "b" --> 0}
I think the briefest expression of what you wanted is...
temp = { a = {a = 0, b = 2}, b = {a = 1, b = 0} }
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of ted
Sent: Thursday, August 14, 2003 10:48 AM
To: lua mailing list
Subject: table constructors
I'm trying to construct a 2d associative array like this
temp = {"a", "b"}
temp["a"] = {"a" = 0, "b" = 2}
temp["b"] = {"a" = 1, "b" = 0}
What's wrong with the syntax? I'm trying to achieve this..
temp = {"a", "b"}
temp["a"] = {}
temp["a"]["a"] = 0
temp["a"]["b"] = 2
temp["b"] = {}
temp["b"]["a"] = 1
temp["b"]["b"] = 0
thanks