Template Engine language reference > Arrays > Array functions > .add()

.add()
This array function adds an element to an array. You can use .add(<value>) to add a new element at the end of an array, or .add(<index>,<value>) to add a new element at a specific position in the array. All elements with higher indexes in the original array are moved one step when you use .add(<index>,<value>).
Example 7
Template
#set($array=[2,4,8])
$array
$array.add(10)
$array
$array.add(2,6)
$array
Output
[2, 4, 8]
[2, 4, 8, 10]
[2, 4, 6, 8, 10]
 
OpenText StreamServe 5.6.2 Updated: 2018-01-26