I want to get length of an array/table.
local mytable = {one = {value = 1}, two = {value = 2}} print(#mytable) print(table.getn(mytable))
Both will return 0. I want to find the way that will print 2 in this situation.
You can't use the length operator on dictionaries, you'd have to loop through it.
local mytable = {one = {value = 1}, two = {value = 2}} local function countNumberOfIndexes(thisTable) local count = 0 for i,v in pairs(thisTable) do count = count + 1 end return count end print( countNumberOfIndexes(mytable) )