Variables
Variables are named slots for storing values. You define a new variable in Zaidlang using the =
operator, like so:
This creates a new variable a
in the current scope and initializes it with the result of the expression following =
. Once a variable has been defined, it can be accessed by name as you would expect.
Scope
Zaidlang has true block scope: a variable exists from the point where it is defined until the end of the block where that definition appears.
Variables defined at the top level of a script are top-level, or global. All other variables are local. Declaring a variable in an inner scope with the same name as an outer one is called shadowing and is not an error.
Last updated