mirror of https://gitee.com/bigwinds/arangodb
Docs: variables are immutable (LET)
This commit is contained in:
parent
3d45439c15
commit
f748bab31e
|
@ -2,12 +2,23 @@
|
||||||
|
|
||||||
The *LET* statement can be used to assign an arbitrary value to a variable.
|
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 variable is then introduced in the scope the *LET* statement is placed in.
|
||||||
|
|
||||||
The general syntax is:
|
The general syntax is:
|
||||||
|
|
||||||
```
|
```
|
||||||
LET variableName = expression
|
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
|
*LET* statements are mostly used to declare complex computations and to avoid
|
||||||
repeated computations of the same value at multiple parts of a query.
|
repeated computations of the same value at multiple parts of a query.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue