The title says it all, for example:
local amongUsIsntFunnyAnymore do
end
The title says it all, for example:
local amongUsIsntFunnyAnymore do
end
There is no difference between
local var do
end
and
local var
do
end
.
A do block is used so that local variables defined inside are not visible from outside the block (this is called lexical scoping). The code you provide with the do block being started on the same line as the variable declaration is usually used when defining local variables specific to the initialization of the variable as in
local var do
local initValue1 = ...
local initValue2 = ...
local initValue3 = ...
var = someComputation(initValue1, initValue2, initValue3)
end
This way, the initialization values do not clutter up the global scope.
So to confirm, do blocks let variables set themself inside of them, to do something that you haven’t done yet?
They let variables set themselves inside of them without being visible or accessible from outside the do block.