Chapter 4: Working with Tables
Downloads
This chapter does not have any code to download
Table of Contents
- Chapter 4: Working with Tables - 53
- Storing Data Using Tables - 53
- Creating and Indexing Tables - 54
- Clearing an Element from a Table - 54
- Shortcuts for String Keys - 55
- Creating Populated Tables - 55
- Using Tables as Arrays - 56
- Creating an Array - 57
- Getting the Length of an Array - 57
- Adding Elements to an Array - 58
- Removing Elements from an Array - 60
- Sorting the Elements of an Array - 61
- Using Tables as Namespaces - 61
- Creating a Namespace of Utility Functions - 62
- Adding Functions to a Namespace - 62
- Storing an Existing Functions - 62
- Defining a New Function - 63
- Object-Oriented Programming with Tables - 63
- Creating a Non-Object-Oriented Counter - 63
- Using Tables as Simple Objects - 64
- Using : to Call Object Methods - 65
- Defining Functions Using : - 66
- Making a Better Counter - 67
- Extending Tables with Metatables - 68
- Adding a Metatable - 68
- Defining Metamethods - 69
- Defining Basic Arithmetic Using __add, __sub, __mul and __div - 70
- Defining Negation Using _unm - 71
- Creating Meaningful Output with __tostring - 71
- Concatenating Tables Using __concat - 72
- Exploring Fallback Tables with __index - 72
- Catching Creationg of Keys with __newindex - 74
- Bypassing Metatables - 75
- value = rawget(tbl, key) - 75
- rawset(tbl, key, value) - 76
- Summary - 76
Errata
There is no errata listed for this chapter yet