Q:

How to combine array in groovy?

The following java code exists but I'm trying to convert it to groovy.  Should I simply keep it as is w/ the System.arraycopy or does groovy have a nicer way to combine arrays like this?
  byte[] combineArrays(foo, bar, start) {
    def tmp = new byte[foo.length + bar.length]
    System.arraycopy(foo, 0, tmp, 0, start)
    System.arraycopy(bar, 0, tmp, start, bar.length)
    System.arraycopy(foo, start, tmp, bar.length + start, foo.length - start)
    tmp
  }

Thank you

A:

def a = [1, 2, 3]
def b = [4, 5, 6]

assert a.plus(b) == [1, 2, 3, 4, 5, 6]   
assert a + b     == [1, 2, 3, 4, 5, 6]

A:

If you want to use an array:
def abc = [1,2,3,4] as Integer[] //Array
def abcList = abc as List
def xyz = [5,6,7,8] as Integer[] //Array
def xyzList = xyz as List

def combined = (abcList << xyzList).flatten()

Using Lists:
def abc = [1,2,3,4]
def xyz = [5,6,7,8]
def combined = (abc << xyz).flatten()

A:

def a = [1, 2, 3]
def b = [4, 5, 6]
a.addAll(b)
println a

>> [1, 2, 3, 4, 5, 6]

