Tables as Objects
Objects vs Values
- Object types in Lua have references rather than values
- Object types in Lua: functions, tables (also thread like structures and userdata)
The differences are shown in the following
- The Table data structure requires both memory and code to access its elements
-- constructor expression planets = {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"} a = planets -- passes a reference to the table data structure print(a[1]) -- uses the syntax for accessing the data structure b = 5 -- initialize a memory location c = b -- move the data to a new memory location print(c) -- print the content of a memory location