How to create a collection/array in size N with each cell initialized to zero in Groovy?

groovy

Solution

Yep, the `Collection#multiply` (or `*`) method:

assert [0] * 3 == [0, 0, 0]

Problem

Is there a short way to create a collection/array in size N with each cell initialized to zero in Groovy? Can't seem to find it on http://groovy.codehaus.org/JN1015-Collections For example ``` arr = func(3) ``` would result in ``` arr = [0, 0, 0] ```

Original source