Ref
| Name |
Mandatory |
Description |
Default |
Type |
⬅️ Input |
|
The value to be set to the variable. |
|
Any |
Output ➡️ |
|
The input value is passed through as the output. |
|
Any |
Name |
No |
The name of the variable. |
`` |
StringVar(Any) |
Key |
No |
The key of the value to read from the table (parameter applicable only if the target variable is a table). |
none |
Any |
Global |
No |
If the variable is available to all of the wires in the same mesh. |
false |
Bool |
Overwrite |
No |
If the variable should be overwritten if it already exists. |
false |
Bool |
Creates an immutable reference variable. Once created this variable cannot be changed.
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 | ; ; create an immutable string variable (by default available only to current wire)
"Hello" | Ref(Name: svar)
svar | Log("svar") ; ; => svar: Hello
; ; uncomment next line to see the immutable-variable-update error
; ; 20 | Update(svar)
; ; => Error composing shard: Set/Ref/Update, attempted to write an immutable variable.
; ; create an immutable numeric variable (available to all wires because `Global: true`)
100 | Ref(Name: nvar Global: true)
nvar | Log("nvar") ; ; => nvar: 100
; ; create an immutable sequence
[10 20] | Ref(Name: seq)
seq | Log("seq") ; ; => seq: [10, 20]
; ; create an immutable table
Const(["a" "b"]) | Ref(Name: "table" Key: "key1")
table | Log("table") ; ; => table: {key1: [a, b]}
; ; Using `Ref` aliases
; ; `=` is alias for `| Ref(Global: false)`: create an immutable string variable:
"World" = svarA
svarA | Log("svarA")
|