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@_ => ._@
}
}
Last updated
Was this helpful?