lua-users home
lua-l archive

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


What kind of errors are you seeing? 

If I run your example, it works fine for me. Example:

print(array["a"]["a"][1]) -- returns 1
print(array["a"]["b"][1]) -- returns 1
print(array["b"]["a"][1]) -- returns 2
print(array["b"]["b"][1]) -- returns 2

Is it possible that you don't want the "{}" around the values 1 and 2
below? 

Tim


-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of orangeted
Sent: Wednesday, June 18, 2003 11:08 AM
To: lua mailing list
Subject: 2d arrays

I'm trying to make a 2d array which uses strings as indices. I've tried
this
but i get errors. what am I doing wrong?


array = {a,b}
array["a"] = {}
array["b"] ={}

array["a"]["a"] = {1}
array["a"]["b"] = {1}

array["b"]["a"] = {2}
array["b"]["b"] = {2}