LuLua · Lesson 3 of 8
Tables — The Only Data Structure
Lua has exactly one data structure: the table. It's an array, a dictionary, an object, and a module all at once. Understand tables and you understand Lua.
◆ Note
ipairs walks 1, 2, 3... and stops at the first nil — use it for arrays. pairs visits every key in no guaranteed order — use it for dictionaries. Accessing a missing key returns nil rather than erroring.
ipairs walks 1, 2, 3... and stops at the first nil — use it for arrays. pairs visits every key in no guaranteed order — use it for dictionaries. Accessing a missing key returns nil rather than erroring.