in java I can create byte array: byte[] array = new byte[] { 0, 0, 0, 0, 0 };
but this construct is invalid in groovy. How I can create byte array in groovy ?
3 Answers
The following should suffice:
def array = [0, 0, 0, 0, 0] as byte[]
Have a look here for more details on arrays in groovy.
Comments
You can't initialize a literal array the same way because Groovy thinks the curly brackets form a closure. What you want is something like
def x = [ 0, 0, 0, 0, 0 ] as byte[]
See more: here