Is there a difference between `local function` and `local test = function`

So I’ve been making function variables like

local Test = function ()

and I just found out there’s one to do like

local function Test()

what’s the difference between these two? If there is one, which should I be using?

They are identical as far as I’m concerned; they both declare a function and store a local reference to it

Use whatever you prefer

1 Like

"There is a difference in their scopes.

local function Test()

Can be accessed as an upvalue for recursion, while the other one can not."

Taken from this response, suggest reading through it:

1 Like
local function Function1()
	Function1() -- You can call itself
end

local Function2 = function()
	Function2() -- You can't call itself
end
1 Like
local function Function1()
	Function1() -- You can call itself
end

local Function2 = function()
	Function2() -- You can't call itself
end

local Function3; Function3 = function()
    Function3() -- You can call itself
end
1 Like