July 2018
Beginner
202 pages
5h 42m
English
Complementary to the setmetatable method, you can retrieve the meta table of a table using the getmetatable method. getmetatable takes only one argument, a table. If the table provided has a meta table, the meta table will be returned, otherwise getmetatable will return nil:
x = {}y = {}z = {}setmetatable(y, z)print (getmetatable(x))print (getmetatable(y))
This will print nil for x, as it has no meta table, and some large, random number for y. This large, random-looking number is the unique ID for table z.