Douglas Seifert wrote in post #1034017:
>>
>> > a = Array.new(1e6+1) {|n| ""}
>>
>
> The above creates an Array of 1,000,001 slots.  The block syntax lets
> you
> provide a default object dynamically.  The first time you reference a
> particular index in the array, the block is called to allocate the
> default
> object at that position.
>

Hi Doug,

Thanks for the explanation.
Didn't understand the Array initialization part.
What's the difference between Array.new(1e6+1) {|n| ""} and
Array.new(1e6+1, "")?

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