8000 block · brombres/Rogue Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Abe Pralle edited this page Sep 7, 2022 · 9 revisions

Syntax

block
  ...
endBlock

block var1=value, var2
  #               ^ equivalent to var2=var2
  ...
endBlock

Description

  • 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.

Example

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
Clone this wiki locally
0