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]
Yep, the Collection#multiply
(or *
) method:
assert [0] * 3 == [0, 0, 0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With