Ref¶
Name | - | Description | Default | Type |
---|---|---|---|---|
<input> |
Input becomes the value of the variable being created. | Any |
||
<output> |
The input to this shard is passed through as its output. | Any |
||
Name |
The name of the variable. | "" |
String &Any |
|
Key |
The key of the value to read from the table (parameter applicable only if the target variable is a table). | None |
String &String |
|
Global |
If the variable is available to all of the wires in the same mesh. | false |
Bool |
|
Overwrite |
If the variable should be overwritten if it already exists. | false |
Bool |
Creates an immutable variable with a constant value. Once created this variable cannot be changed.
Details¶
Ref
creates an immutable variable and assigns a constant value to it. Once created this variable cannot be changed.
The name of the variable comes from the :Name
parameter and the constant value comes from the input. The type of input controls the kind of variable that will created: numeric input creates numeric variable, string input creates string variable, and sequence input would create a sequence variable.
To create a table variable, along with the input, you also have to pass the key in the :Key
parameter. In this case the input (whatever it may be - numeric, string, sequence) becomes the value of the key that was passed in parameter :Key
.
The :Global
parameter controls whether the created variables can be referenced across wires (:Global
set to true
) or only within the current wire (:Global
set to false
, default behaviour).
The input to this shard is used as the value for the new variable and is also passed through as this shard's output.
Note
Ref
has two aliases: =
and &>
. Both are aliases for (Ref ... :Global false)
. See the code examples at the end to understand how these aliases are used.
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 26 27 28 29 |
|
[info] [shards/General/Ref/Ref.edn] .svar: Hello
[info] [shards/General/Ref/Ref.edn] .nvar: 100
[info] [shards/General/Ref/Ref.edn] .seq: [10 20]
[info] [shards/General/Ref/Ref.edn] .table: {key1: [a b]}
[info] [shards/General/Ref/Ref.edn] .svarA: World
[info] [shards/General/Ref/Ref.edn] .nvarA: 100