Understanding ipairs

The ipairs iterator is used to iterate over arrays. ipairs returns two variables—let's call them i and v. The i variable will hold the index of the element being iterated over, v will hold the value of the element. The following code demonstrates using ipairs to iterate over an array:

days = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" }

for i, v in ipairs(days) do
print ("index: " .. i .. ", value: " .. v)
end
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.129.253