Hi,
In message "[ruby-talk:6401] Array.fill with block?"
on 00/11/17, Hugh Sasse Staff Elec Eng <hgs / dmu.ac.uk> writes:
|
|Does anyone else think that it might be a good idea for Array.fill to take
|a block to compute the value for each successive element? I'm thinking
|that it might be faster/more efficient than Array.collect! because it need
|not pass in the value each time. It could pass in the index number,
|perhaps.
You mean that Array#fill with a block should be faster since it
doesn't have to retrieve the element? I don't think so. Retrieving
an array element in this case costs only a few machine instructions
for each element, I believe.
matz.