Hi, I have been studying a lot about loops, I seem to understand everything, except "In Pairs". I can't find any good explanations in the wiki, so I was wondering if anyone could just spare some time to help me out.
Any help would be appreciated. Greatly.
Great question.
So when using a for loop you can either do
List = {1,2,3,4,5,6,7,8,9,10} for i = 1, #List do --#List just gets the length of the list print(List[i]) end
this will print all of the values of the list by adding + 1 to i every time so it prints a different value every cycle.
however, if you do in pairs like so
List = {1,2,3,4,5,6,7,8,9,10} for i, value in pairs(List) do print(value) end
You will be able to actually just print value, instead of index through the List like the regular for loop.
These both will do the same thing but in some situations it is definitely better to choose one or the other.