I want to loop through each key in a dictionary and then if the key’s value is a dictionary,table to loop through that too.
local testDictionary = {
FruitName = "Lemon",
FruitColor = "Yellow",
Sour = true,
test = {hello = "one"}
}
for key, value in pairs(testDictionary) do
print(key, value)
end
here I have tried to see what would happen and the result is strange:
test table: 0x6410c3bccefa9afd
FruitName Lemon
FruitColor Yellow
Sour true
It seems that when looping through, it tells you in a string a bunch of characters most likely encoded from the actual table/ dictionary. How would I quickly determine if the value is a table? It seems that this is possible indirectly by simply taking the string result and determining if the name has the word table. Also if you could, id like to see this combined with getting the values of the table inside the dictionary. I think I would know where to go after determining if table but I want to make sure.
both are informational. I just wanted if its a table but its good to consider the type of the table too. Currently testing out tables and dictionaries inside of a dictionary
After looking at the link you gave, I noticed that it only gives
“nil” (a string, not the value nil), “number”, “string”, “boolean”, “table”, “function”, “thread”, and “userdata”
Is is possible to determine if the value is a dictionary too?
Since there’s no strict definition of what’s considered a dictionary, an array, or a mixed table, there’s no built-in function to do that. You’d have to settle with something like what Advanced linked, even if it’s a bit arbitrary.