Wun Code
Lua

Lua Tables and Objects

The table is Lua's only data structure, and you build arrays, dictionaries, objects and classes out of it.

Start the trackFree, no sign-up needed

What you'll learn

  • TablesAn array and a dictionary in one structure
  • Looping over a tableipairs for lists and pairs for dictionaries
  • The table libraryInsert, remove, join and sort
  • Tables inside tablesSafe access to deep fields
  • Holes in listsRemove with table.remove, not nil
  • Default valuessetmetatable and the __index field
  • A class from a tableMethods, self and the colon
  • Inheritance with tablesBuild on the parent and override its method
  • Operators on your objectsDefine addition, equality, comparison and string conversion
  • Turning a table into a stringRecursion and a fixed key order

Track contents

10 lessons, 2 hours in total
  1. 1TablesLuaAn array and a dictionary in one structure
  2. 2Looping over a tableLuaipairs for lists and pairs for dictionaries
  3. 3The table libraryLuaInsert, remove, join and sort
  4. 4Tables inside tablesLuaSafe access to deep fields
  5. 5Holes in listsLuaRemove with table.remove, not nil
  6. 6Default valuesLuasetmetatable and the __index field
  7. 7A class from a tableLuaMethods, self and the colon
  8. 8Inheritance with tablesLuaBuild on the parent and override its method
  9. 9Operators on your objectsLuaDefine addition, equality, comparison and string conversion
  10. 10Turning a table into a stringLuaRecursion and a fixed key order