moonscript
moonscript copied to clipboard
return and assignment on same line?
return foo = -> foo!
..would compile to:
local foo
foo = function()
return foo()
end
return foo
Apart from returning a function that calls itself, another use case is expecting the last assignment in a function to implicitly return:
i = 0
incr = -> i += 1
..would compile to:
local i = 0
local incr
incr = function()
i = i + 1
return i
end