Monday, September 10, 2012

Groovy Tip: append list

Groovy provides plus method to append a new list to an existing list at a specified index

public List plus(int index, List additions)
e.g.
def items = [1, 2, 3]
def newItems = items.plus(2, 'a'..'c')
will result in [1, 2, 'a', 'b', 'c', 3]

No comments:

Post a Comment