I've tried this:
function RandomFuncThatDoesNothing()
-- Some random code
end
print(tostring(RandomFuncThatDoesNothing())
Does not work out so well for me.
I've tried this:
function RandomFuncThatDoesNothing()
-- Some random code
end
print(tostring(RandomFuncThatDoesNothing())
Does not work out so well for me.
Function values don't have names. Your code is equivalent to
RandomFuncThatDoesNothing = function() end
ie, the name is not part of the function itself; you've just save the function itself to some variable.
If you want to have a collection of functions identified by their name, use a table and keep their keys in your variables:
local SPECIAL = {
alpha = function() end,
beta = function() end,
}
local f = "alpha"
-- To call f
SPECIAL[f]("hi")
print(f) --> alpha, since f is actually just a string
This discussion is preserved as it was. New answers, comments, and votes are closed.