Can you set an array

I can find the syntax for getting an array value in a template but what is the syntax for setting a value to a particular array position? Or can you?

I believe you can declare an array like…
#set($sizes = [ “57”,“72”,“114”,“144” ])

And you can retrieve a particular position…
$tools.list.get($sizes ,1)

But can you set an array position in a template?
#set($size[1] = “72”)

Hi Mark,

There are a couple of ways to do this. Since you are using the list tool, here is an example:

<h2> Array Examples using List Tools</h2>
#set($primes = [2, 3, 5, 7])##
<h3> List Size</h3>
List Size: $tools.list.size($primes)
List Get:  $tools.list.get($primes, 2)
List Set:  $tools.list.set($primes, 2, 1)   -> (Set array element at index 2 = 1) <br/>
After Set:  $tools.list.get($primes, 2)
Check if List is Empty: $tools.list.isEmpty($primes)
Check if List contains an element: $tools.list.contains($primes, 7)

$tools.list.set is the one to set an element.

-n