Assignment
The variable is dynamic typed and is defined as local by default. But you can change the scope of declaration by local and global statement.
hello = "world"a, b, c = 1, 2, 3hello = 123 -- uses the existing variablehello = "world"a, b, c = 1, 2, 3hello = 123 -- uses the existing variablePerform Update
Section titled “Perform Update”You can perform update assignment with many binary operators.
x = 1x += 1x -= 1x *= 10x /= 10x %= 10s ..= "world" -- will add a new local if local variable is not existarg or= "default value"x = 1x += 1x -= 1x *= 10x /= 10x %= 10s ..= "world" -- will add a new local if local variable is not existarg or= "default value"Chaining Assignment
Section titled “Chaining Assignment”You can do chaining assignment to assign multiple items to hold the same value.
a = b = c = d = e = 0x = y = z = f!a = b = c = d = e = 0x = y = z = f!Explicit Locals
Section titled “Explicit Locals”do local a = 1 local * print "forward declare all variables as locals" x = -> 1 + y + z y, z = 2, 3 global instance = Item\new!
do local X = 1 local ^ print "only forward declare upper case variables" a = 1 B = 2do local a = 1 local * print "forward declare all variables as locals" x = -> 1 + y + z y, z = 2, 3 global instance = Item\new!
do local X = 1 local ^ print "only forward declare upper case variables" a = 1 B = 2Explicit Globals
Section titled “Explicit Globals”do global a = 1 global * print "declare all variables as globals" x = -> 1 + y + z y, z = 2, 3
do global X = 1 global ^ print "only declare upper case variables as globals" a = 1 B = 2 local Temp = "a local value"do global a = 1 global * print "declare all variables as globals" x = -> 1 + y + z y, z = 2, 3
do global X = 1 global ^ print "only declare upper case variables as globals" a = 1 B = 2 local Temp = "a local value"