Var Op

This operation sets or returns a variable.

Definition: ["var", <name: expression(string), string> [, <value: expression(any)>]]

  • <name: expression(string), string> - represents a name which will be get or set. If value is not set then this operation will return an already set variable by this name or null if there was no variable set previously.

  • <value: expression(any)> - [Optional value]. If it's set then this operation will set a variable to the value evaluated in this expression. If this is set then this value will also be return as a result of this operation.

When reading, the name supports the same dot syntax as get: if a variable holds an array, ["var", "user.user_id"] returns the nested value. You always set the whole variable by its plain name.

Usage

Request:

["sequence",
  ["var", "test", ["value", 55]],
  ["var", "test"]
]

Response:

55

Typical Usage

This operation is typically used together in sequence operator in order to store a state during a request so that it can be used as a value in one of the other operations in a sequence.

Using it alone in a request will not have any visible effect.