|
|
|
|
|
by Anaminus
1240 days ago
|
|
This is a thing in Lua as well, with do-end blocks: local foo
do
local bar = 42
-- Same as `foo = function() ... end`, so this sets the local foo variable.
function foo()
return bar
end
end
Because Lua has no significant whitespace, it can be made to look like some kind of specific syntax: local foo do
local bar = 42
function foo()
return bar
end
end
Though I think this is too clever, so I like to insert a semi-colon to make it clear what is happening: local foo; do
local bar = 42
function foo()
return bar
end
end
|
|