I’m trying to figure out a good way to extend an Array, when the items
may not be added in index order, and I don’t know the final highest
index. Does anyone have any suggestions?
What occurs to me is that I could double the length of the array
whenever I want to add more than one element by doing something like:
a = a + Array.new(a.length)
Naturally, it would need to be a bit more complicated, as, e.g., I’d
need to ensure that the resulting array actually would hold the
proposed index. Still, something only a little more complicated should
work, but is that the best approach?