for i,v in pairs("")do --Code end
This code has been in my head for a while and I really want to know how to use it. Can someone give me a link or answer my question? Thanks.
for i,v in pairs() is used whenever you want to loop through a table or dictionary. For example:
local MaTable = {"Thing 1", "Thing 2", "Thing 3"}
for i,v in pairs(MaTable) do -- this will go through "Thing 1", "Thing 2" and "Thing 3"
the i and the v in the loop is variables for the loop. i stands for how many time the code have gone through the table
for i,v in pairs() do print(i) end -- this will print: 1 2 3 Because it looped through the table three times.
the v in the loop stands for what item the code is on
for i,v in pairs(MaTable) do print(v) end -- this will print: Thing 1 Thing 2 Thing 3 Because those are the items in the table