I would like to initialize ArrayBufferwith a value of -1 in indices from 0 to 99. Is there a simple, idiomatic way to do this?
This works, but it's a little cool:
val a = new ArrayBuffer [Int] ()
a.appendAll (Nil.padTo (100, -1))
I would like to see something like this:
val a = ArrayBuffer (List (-1) * 100)
source
share