☄️
SpaceTode
  • Introduction
  • Element
  • Properties
  • Data
  • Arguments
  • Rules
  • Diagrams
  • Inputs
  • Outputs
  • Transformations
  • Symmetries
  • Symbols
  • Event Arguments
  • Maybe
  • Point of View
  • Actions
  • Mimic
  • Sub-Elements
  • Blocks
  • Scoping
  • JavaScript
  • Behave
  • Tabs and Spaces
Powered by GitBook
On this page

Was this helpful?

Scoping

Symbols that you declare are block-scoped. They only exist inside the block that they are declared in. This code causes an Unidentified Symbol error because the E symbol doesn't exist in the scope of the diagram:

element Sand {
    {
        symbol E Empty
    }
    
    @ => E
    E    @
}

It can be useful to scope different parts of your code so that you can keep track of what different symbols mean:

element Sand {
    {
        symbol W Water
        @ => W
        W    @
    }
    {
        symbol W Wind
        W@_ => ._@
    }
}
PreviousBlocksNextJavaScript

Last updated 4 years ago

Was this helpful?