What does the index mean in (for’s first argument), what does it do?
if i put this topic in the wrong place then please correct me since im new to the devforum
What does the index mean in (for’s first argument), what does it do?
if i put this topic in the wrong place then please correct me since im new to the devforum
The two values returned by the iterator are the item’s key in the dictionary and the item itself.
local someDictionary = {
["index 1"] = 5,
["index 2"] = "hello",
[game.Workspace.Part] = true
}
for index, value in pairs(someDictionary) do
print(tostring(index)..": "..tostring(value))
end
would print:
index 1: 5
index 2: hello
Part: true
Although unless you are using integers as your indices and iterating with ipairs, the order in which key/value pairs are iterated may not be guaranteed to be the same as how it is defined in the script.
Thank you for the explanation this could probably help me in a lot of stuff in the future.