new statements initialize new variables into the current context.
You cannot use a variable that has not been declared previously.
By using the
new statement you create a new variable with a
certain name. Variable names can be any combination of alphanumerical
characters, but it may not begin with a number. For improved readability, the
_ may also be used at any place in
a variable name.
-- declaring a new variable: new myVar -- declaring a variable and assigning a value to it right away: new myNumber = 2
new fls = (:) for a = 1,10,2 fls += a print(fls)
(: 1 3 5 7 9 )
Extracting from a List
Optionally, you can extract a keyed entry from a list and use its value as a new local variable:
new myList = (: a=10 b=20 c=30) new a, b, c in myList print(a b c)
10 20 30