On Apr 19, 2009, at 1:17 PM, Yoann G. wrote:
ary[ary.index(e)] = foo(e)
ary[ary.index(e), 12] = [flublu]
Sure, i could use map or many other ways, my code is quite ugly
Yeah, for a case like this, I would probably just resort to tracking
an index in a variable and using a boring while loop. 90% of the time
it’s wrong to track your own index in Ruby, but I think you’re
squarely in the special 10% here.
Really, you should already be using each_with_index() above because
your repeated calls to index() are inefficient for big data sets
(rewalking possibly large portions of the Array) and they break if the
data set contains duplicate entries.
Plus, I’m just not comfortable relying on the iterators to do the
right thing while I edit the collection out from underneath them.
Obviously it was working for you, but I’m not confident enough to
trust it under all cases.
I don’t see the point in removing capabilities from the language
(restarting an iteration from within), but I can sure live with it.
It was done because retry had some nasty side effects and was causing
James Edward G. II