I'm looking for the best way to initialize an array by specifying its size and a default value (here the default value will be "").
For example if i've got :
def myTab = ["","","","","","","","",""]
How can i initialize this same array without writing each field, only by changing the size and/or default value ?
Something like
def myTab = new String[9] //(combined with a 'withDefault' method equivalent)
You could do:
def myTab = [""] * 9
Btw, that's a list, not an array
If you really need an array (which you probably don't), you can do
String[] myTab = [""] * 9
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