getmetatable

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.59