Re: "addition" of lists

Sergiu Dumitriu <[email protected]>
Newsgroups gmane.comp.jakarta.velocity.user
Message-ID <[email protected]>
On 05/24/2013 01:50 PM, [email protected] wrote:
> Hi!
> 
> Probably I'll use the wrong semantic, but I'll try to explain the very simple result I want to get with Velocity: given two lists of results, let's me call them $list1 and $list2, I want to get a new list, let's call it $listTotal, including all item in $list1 and $list2.
> 
> Please, how could I do that? What is the correct expression I must it in Velocity's World for his operation?
> 
> Thank you so much for your help!
> 
> Ricardo
> 

Hey Ricardo,

If those are indeed lists, they should support all the methods that
Java's List class provides [1], including addAll [2], so this should work:

#set ($listTotal = [])
#set ($discard = $listTotal.addAll($list1))
#set ($discard = $listTotal.addAll($list2))


[1] http://docs.oracle.com/javase/1.5.0/docs/api/java/util/List.html
[2]
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/List.html#addAll%28java.util.Collection%29
-- 
Sergiu Dumitriu
http://purl.org/net/sergiu
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.