Quick table question (keys)..

What am I missing here, I could have sworn this was supposed to work:

1
2
3
4
5
6
guid = {};
guid.used = {};
 
local currentGuid = '8477CFBA-F15C-EFEC-D155-6646D326B3B2';
guid.used[currentGuid] = currentGuid;
print(#guid.used); -- Says 0

Hi Scott,

Maybe this will help....

1
2
3
4
5
6
7
8
9
guid = {};
guid.used = {};
 
local currentGuid = '8477CFBA-F15C-EFEC-D155-6646D326B3B2';
guid.used[currentGuid] = currentGuid;
print(#guid.used[currentGuid]); -- Says 0 ***** this it the length of what's in there
print("what is it: keyed with currentGuid ", guid.used[currentGuid]);
guid.used[0] = currentGuid;
print("What is it: keyed with 0 ", guid.used[0]);

Scott, you need to read up on how tables work in Lua. Because you have set the

1
2
3
local currentGuid = '8477CFBA-F15C-EFEC-D155-6646D326B3B2';
guid.used[currentGuid] = currentGuid;
print(#guid.used); -- Says 0
views:1677 update:2012/2/7 8:40:54
corona forums © 2003-2011