-
Notifications
You must be signed in to change notification settings - Fork 8
block
Abe Pralle edited this page Sep 7, 2022
·
9 revisions
block
...
endBlock
block var1=value, var2
# ^ equivalent to var2=var2
...
endBlock
- A block has its own local scope.
- A block is analogous to an arbitrary
{...}
block of code in a C-family language. - A block can declare local variables that shadow any existing locals of the same name for the duration of the block.
local x=1, y=2
block x=5, y
println "x:$ y:$"(x,y) # x:5 y:2
y = 0
println "x:$ y:$"(x,y) # x:5 y:0
endBlock
println "x:$ y:$"(x,y) # x:1 y:2