unset
Unset specified variables. The variables have been set either using the set
command
or as a byproduct of some other statements or methods (like record
)
Parameters
Name | Type | Description |
---|---|---|
vars | string | string[] | Names of the variables to unset. |
Variable
Any variable can be unset by this method.
Examples
Unset a single variable
- YAML
- JSON
version: 1.0.0
sections:
main:
- set:
num_var: 1
- play: "say: The value of num_var is: %{num_var}."
- unset: num_var
- play: "say: The value of num_var is %{num_var}."
{
"version": "1.0.0",
"sections": {
"main": [
{
"set": {
"num_var": 1
}
},
{
"play": "say: The value of num_var is: %{num_var}."
},
{
"unset": "num_var"
},
{
"play": "say: The value of num_var is %{num_var}."
}
]
}
}
Unset multiple variables
- YAML
- JSON
version: 1.0.0
sections:
main:
- set:
systems:
hr:
- tracy
- luke
engineering:
john: absent
name: john
- play: "say: ${systems.hr}"
- unset:
- systems
- name
# this play statement emits an error because `systems` is undefined
# at this point so there's nothing for `play` to say.
- play: "say: %{systems}"
{
"version": "1.0.0",
"sections": {
"main": [
{
"set": {
"systems": {
"hr": [
"tracy",
"luke"
],
"engineering": {
"john": "absent"
}
},
"name": "john"
}
},
{
"play": "say: ${systems.hr}"
},
{
"unset": [
"systems",
"name"
]
},
{
"play": "say: %{systems}"
}
]
}
}