lua-users home
lua-l archive

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


Try something like this:

  temp = {a={}, b={}}
  temp["a"] = {a = 0, b = 2}
  temp["b"] = {a = 1, b = 0}

Or

  temp = {a={}, b={}}
  temp.a = {a = 0, b = 2}
  temp.b = {a = 1, b = 0}

Or

  temp =
  {
    a = {a = 0, b = 2},
    b = {a = 1, b = 0}
  }

Love, Light and Peace,
- Peter Loveday
Director of Development, eyeon Software


----- Original Message ----- 
From: "ted" <orangeted@hotmail.com>
To: "lua mailing list" <lua@bazar2.conectiva.com.br>
Sent: Thursday, August 14, 2003 11:48 AM
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
>