I am just curious if there is a difference between these two different types of functions.
function PrintHello()
return print("Hello")
end
and
PrintHello = function()
return print("Hello")
I am just curious if there is a difference between these two different types of functions.
function PrintHello()
return print("Hello")
end
and
PrintHello = function()
return print("Hello")
Beside that you're missing an end in the second function both snippets are equivalent.
According to the Lua 5.4 Reference Manual 3.4.11 - Function Definitions
translates to
As you'll also find in the manual there is a difference for local functions.
translates to
This allows a to reference itself for example in a recursive call.
Instead of
return print("Hello")
simply writeprint("Hello")
.print
has no return value.