1
0
Fork 0

Docs: variables are immutable (LET)

This commit is contained in:
Simran Brucherseifer 2016-10-17 17:26:00 +02:00
parent 3d45439c15
commit f748bab31e
1 changed files with 11 additions and 0 deletions

View File

@ -2,12 +2,23 @@
The *LET* statement can be used to assign an arbitrary value to a variable.
The variable is then introduced in the scope the *LET* statement is placed in.
The general syntax is:
```
LET variableName = expression
```
Variables are immutable in AQL, which means they can not be re-assigned:
```js
LET a = [1, 2, 3] // initial assignment
a = PUSH(a, 4) // syntax error, unexpected identifier
LET a = PUSH(a, 4) // parsing error, variable 'a' is assigned multiple times
LET b = PUSH(a, 4) // allowed, result: [1, 2, 3, 4]
```
*LET* statements are mostly used to declare complex computations and to avoid
repeated computations of the same value at multiple parts of a query.