Birk
Birk

Reputation: 211

Lua: Is there a way to get a tables metatable

Is there a way to get a tables metatable? e.g.

local tbl = {}
setmetatable(tbl, {__call = function() print("tbl called") end})

-- how to get metatable of tbl?

Upvotes: 2

Views: 986

Answers (1)

Paul Kulchenko
Paul Kulchenko

Reputation: 26794

You can use getmetatable(tbl) to get the assigned metatable (or nil if none is assigned).

Upvotes: 4

Related Questions