I never really understood the in pairs function, and as I get deeper into Lua, I feel like it is really useful, but I just can't understand it, can anyone help me?
How in pairs
works is that unlike a normal for
loop which iterates a certain amount, it iterates through a table/array.
So let's say I have an array with five values, I would call on it like so:
local mytable = {54, 3, 9, 10} for i, v in pairs(mytable) do print(v) end
The loop would print all of the values. Generic for loops like the one above are useful for iterating through an object's children effectively.
If this helped you, don't forget to accept the answer :)
Marked as Duplicate by Perci1
This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.
Why was this question closed?