Formatting table/class functions

I’ve 100% worded the title wrong considering I can’t even name the function name…
I like to store some of my functions in modules like so:

Fns.Epic = function(...)
	local args = {...}
	print(args[1])
end

function Fns:NotEpic(...)
	local args = {...}
	print(args[1])
end

I normally declare my functions using name = function() (like shown in Fns.Epic); However, if you take a look at Fns:NotEpic, I’ve done function name(), although it is not a big deal, I would like to know if there is a way to declare Fns:NotEpic while following name = function()

and before someone says Fns:NotEpic = function(), that does not work

1 Like

: is usually used to implicitly reference self. To create a new function you should create a new key, instead of trying to call a function.

local t = { }

t.NotEpic = function(...)
	local args = {...}
	print(args[1])
end

t:NotEpic() -- self
t.NotEpic() -- nil
2 Likes
local Fns = {}

Fns.NotEpic = function(self)
	print(self)
end

Fns:NotEpic()

Not exactly what you asked for.

2 Likes