Referencing tables

How would I print [“Gorilla Fang”] and not the values in this table?

local data = {
		["Gorilla Fang"] = {
		Price = 300000,
		MinResell = 200000,
		MaxResell = 800000
	},

}

Iterate through your dictionary and print it’s index.

for i, v in data do
    print(i, v) -- Gorilla Fang table... {...}
end

Just simply loop through the data table

for index, value in pairs(data) do
   print(index, value) -- 1,"Gorilla Fang"
end)

Tables consist of keys and values. Keys are left of the = and values are to the right of it. Gorilla fang is a key. We can loop through the table, and print all keys.

for key, value in data do
  print(key)
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.