On Fri, 25 May 2001, Martin Julian DeMello wrote: > I'm trying to write an each! iterator that will iterate over an object > (specifically, an array) and pass a modifiable reference to its contents, so > I can say something like > > a=[1,2,3,4,5] > a.each! { |i| i++ } # [2,3,4,5,6] You can use Array#map! to do this. irb(main):001:0> a=[1,2,3,4,5] [1, 2, 3, 4, 5] irb(main):002:0> a.map! {|i| i+=1} [2, 3, 4, 5, 6] irb(main):003:0> a [2, 3, 4, 5, 6] > > Is this possible? Already existing? Possible, but ugly? 'RTFM' is fine, as > long as you tell me which FM to R :) RTFM stands for Read the Fine Manual. 8-) right? > > -- > Martin DeMello > ========================================================= Jim Freeze jim / freeze.org --------------------------------------------------------- No comment at this time. http://www.freeze.org =========================================================