Charles Hixson wrote in post #1084111:
> 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?

This happens automatically.

>> a = [:foo, :bar]
=> [:foo, :bar]
>> a[10] = :baz
=> :baz
>> a
=> [:foo, :bar, nil, nil, nil, nil, nil, nil, nil, nil, :baz]

As others have said: using a Hash may be more efficient, if there are 
large gaps - but then you may have to sort the keys if you want to 
iterate over it in order. It depends on your use case.

-- 
Posted via http://www.ruby-forum.com/.