Local variables
Last updated
Was this helpful?
Last updated
Was this helpful?
Variables lets us assign data to a named key, which can then later be retrieved or changed.
You can use the Set Variable
node to assign a value to a variable name.
And get the value of a variable using the Get Variable
node.
Any function output can be automatically mapped to a local variable (meaning it automatically sets a local variable to the value of that output after it has been called). You can do this by simply clicking the output property on the function instance. You can then also edit the name if you want to set a different variable.
Note that all places that sets a variable must declare it "mutable" if there is more than one place that sets.
Variables being local means changing a variable in one module or function doesn't affect a variable with the same name in a different module or function. This means you don't have to worry about the same variable already being in use in a different part of your application; you only have to look in the current function/module.
Local variables can be either mutable or immutable (the default). This is a mechanism that helps prevent bugs where two nodes make changes to the same variable without you explicitly declaring that this is OK. You can make a variable mutable by clicking the "mut" toggle button on a setter or getter node, or from a dropdown on the function output property if you are using the .
Note that a variables value does not persist between .