lua-users home
lua-l archive

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


Looks like you don't quite understand table constructors. I suggest you 
re-read that part of the manual. 
 
Here's what you're (probably) trying to do: 
 
array = {} -- creates an empty table called "array" 
array["a"] = {} -- creates an empty table stored in array["a"] 
array["b"] = {} -- creates an empty table stored in array["b"] 
array["a"]["a"] = 1 -- stores 1 in array["a"]["a"] 
etc. 
 
Here's what you're doing: 
> array = {a,b} -- creates an empty table; sets index 1 to "a" and index 2 to 
"b" 
 
> array["a"] = {} -- does the same as in my code 
> array["b"] ={}  -- ditto 
>   
> array["a"]["a"] = {1} -- stores a new table in array["a"]["a"] with one 
entry: key 1 and value 1 
> array["a"]["b"] = {1} -- stores a new table in array["a"]["b"] with one 
entry: key 1 and value 1 
>   
> array["b"]["a"] = {2} -- stores a new table in array["b"]["a"] with one 
entry: key 1 and value 2 
> array["b"]["b"] = {2} -- stores a new table in array["b"]["b"] with one 
entry: key 1 and value 2 
 
I'm sure this isn't what you want.