I need to have a function that returns true when something is a dictionary. I saw a function but it does not work with numerical keys. This is my function
if next(t) == nil then
return "Empty"
end
local Array = true
local Dictionary = true
for k, _ in next, t do
if typeof(k) == "number" and k%1 == 0 and k > 0 then
Dictionary = false
else
Array = false
end
end
if Array then
return "Array"
elseif Dictionary then
return "Dict"
else
return "Mixed"
end
If I give this a dictionary which has numerical key’s it will return an Array. Is there a way to cut it down to only return true if its a dictionary and work with all types of dictionaries whether they be numerical keys or string keys