Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Declare a method with a variable?

Asked by 9 years ago

Is it possible to declare methods with a variable?

local index = {}
for x, r in pairs({'An','Example'}) do
    index:[r] = function () end -- Doing this throws a syntax error
end

rather than

local index = {}
function index:An () end
function index:Example () end

1 answer

Log in to vote
1
Answered by
4Bros 550 Moderation Voter
9 years ago

You can't declare methods with a variable,

Ad

Answer this question