It would work the same was as Array::ofDim. I don’t think there’s a need for Array’s multi-dimensional overloads, since those are uncommon.
There is currently a constructor we can use, but with Scala 3 adding automatic apply methods, having to use new just for ArrayBuffer makes it stick out in my code.
are you trying to specify the initial size? because you can also call sizeHint. ofDim seems odd to me as an ArrayBuffer can grow, and also does not currently respect the exact size
Any particular reason why this method is proposed just for mutable.ArrayBuffer, rather than mutable.Buffer? ArrayBuffer is meant to be just one implementation for Buffer, so you would expect the API to be the same.
As @NthPortal is alluding to, Array is a fixed-size collection, while Buffer is designed to change size, so they are not analogous.
Had no idea that method existed. It might be even faster than the constructor (after initialization) since the implementation maintains the backing array size as a power of 2.
Thanks for the help removing the only new I’ve written in the last week!