Create Variable
Define and initialize a new variable
Define and initialize a new variable in your function stack.
Variables can hold static values, derive from existing variables, or be transformed using actions.
Config
- Value: The initial value of the variable. It can be a raw input (e.g. a string, number) or another variable.
- Action: An optional transformation to apply before assigning the final value to the variable.
Example 1: Create a Simple Variable
In this example, we create a variable called personName
with a raw string value "rebaz"
.
Example 2: Change Variable Type
We create a variable named personAge
and provide the value 30
as an Int
.
Example 3: Transform Value with Action
Here, a variable called transformedRes
is created with value 2025
, with type of Int64
.
Then the action To Result
is applied to wrap the value as a Result
.
Available actions include:
- Force Unwrap: Forcefully unwrap the value (panics if invalid).
- To Optional: Wraps the value as an optional.
- To Pointer: Converts to a pointer (used when passing by value is not enough). in most cases, you don't need this.
- To Result: Wraps the value in a
Result
, containing either data or error.
Example 4: Create from Existing Variable
Create a new variable name2
using the value from an existing variable personName
.
Example 5: Create from Existing Variable + Transform
Create a variable age2
from existing personAge
and apply the To Optional
transformation.
Example 6: Extract from Struct Field
Extract a field from a struct into a new variable.
In this case, type
is selected from a nested field within a previously created struct variable.
Select the struct variable
Choose the struct instance
Pick the specific field
Example 7: Create a Late Variable
Declare a variable without assigning an initial value — useful when the value will be set later (e.g. inside a loop or condition block).
Set the variable name and type, then in the action selector, choose Change To Late Var
.