title: velocity template drop element from array
body: <p>I'm trying to get the last element of an array in a velocity template dropped before joining it together into a string and showing the result in the "className": key below:  </p>
  
  <pre><code>    #set($elem = '"System.NotImplementedException: Test Exception')
      #set($trace = $elem.replace('"',""))
      #set($tracearray = $trace.split("\."))
      #set($arraysize = $tracearray.size())
      #set($lastelem = $tracearray.size() - 1)
      {
        "className":$tracearray.remove($lastelem).toString(),
        "method":"$tracearray[$lastelem]"
      }#if($foreach.hasNext),#end
      #end
    ]
  </code></pre>
  
  <p>I've tried several different ways to get the array to drop the element and join it together into a string but haven't had any luck so far.</p>
  
  <p>From the above example I'm looking for the following output to be achieved.</p>
  
  <pre><code>{
    "className":"System",
    "method":"NotImplementedException: Test Exception"
  }
  </code></pre>
  
  <p>The <code>$elem</code> variable will be holding strings of various lengths and with a different number of <code>.</code>'s in them to split on so the lengths of the arrays will vary.</p>