Both of your examples would work exactly the same. The only time there would be a difference between them is if they were declared as local and were for a recursive function.
Code:
local function TestA(x)
x = tonumber(x) or 0
print("TestA", x)
if x > 0 then
TestA(x - 1)
end
end
TestA(1)
local TestB = function(x)
x = tonumber(x) or 0
print("TestB", x)
if x > 0 then
TestB(x - 1)
end
end
TestB(1)
In that example TestA would work fine but TestB would throw an error about trying to call a global TestB that is nil. The reason TestB throws an error is that the right side of the = is processed first so the function is created before the local variable it will be saved to. To make TestB work like TestA and still be local you would have to do:
Code:
local TestB
TestB = function(x)
x = tonumber(x) or 0
print("TestB", x)
if x > 0 then
TestB(x - 1)
end
end
TestB(1)