Here is a code:
users = {}
users["aaa"] = "bbbb";
users["bbb"] = "bbbb";
users["ccc"] = "bbbb";
print("Users count ", table.getn(users));
Why table.getn(users) always returns 0? BTW, #users returns 0 too. So, am I doing something wrong and there is another way to get the amount of elements in the array?
table.maxn and # look for numeric indices; they won’t see your string indices.
As for getting the number of elements in an array with arbitrary indices, I’d probably walk the array using something like:
but I’m an idiot.