In CoyoteScript, variables can hold map or list based collections. These collections can be manipulated and read from through collection operations.
These operations include:
- “+” or “add” to add a value to a collection.
- “-” or “remove” to remove a value from a collection.
- “+>” or “include” to add multiple values to a collection as individual values.
- “->” or “exclude” to remove multiple values from a collection as individual values.
Example:
$list1 = 1, 2, 3 $list1 + 4 $list1 - 2 $list2 = 5, 6 $list1 +> $list2 print $list1 > (1, 3, 4, 5, 6)
List values can be accessed by their position by putting the list inside parenthesis followed by the position index.
Example:
$list = a, b, c print ($list 2) > b
Map values can be accessed by the key value of an item in the map by putting the map inside parenthesis followed by the value of the key.
Example:
$map = a: dog, b: cat, c: bird print ($map b) > cat