Skip to Content
Lua Quick Start Guide
book

Lua Quick Start Guide

by Gabor Szauer
July 2018
Beginner
202 pages
5h 42m
English
Packt Publishing
Content preview from Lua Quick Start Guide

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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Lua Programming

Beginning Lua Programming

Kurt Jung, Aaron Brown
Vim Masterclass

Vim Masterclass

Jason Cannon

Publisher Resources

ISBN: 9781789343229Supplemental Content