Ericson Willians
Ericson Willians

Reputation: 7845

Is it possible to list all the functions of a table?

I'm new to the Lua Programming Language and I can't find a way to list all the existent functions that were defined in a given table. I've checked the documentation for the debug table and it's possible to get the details only of functions, not of whole tables.

Is there something like the dir() function of the Python Interpreter in Lua? Is it possible to list all the methods/functions of a table?

Upvotes: 4

Views: 2441

Answers (1)

warspyking
warspyking

Reputation: 3113

Iterate and print? Or am I not understanding the question?

for i,v in pairs(table_here) do
    if type(v) == "function" then
        print(i,v,debug.getinfo(v))
    end
end

Upvotes: 6

Related Questions