Hee-Sob Park <phasis / hananet.net> wrote:
> "Martin Julian DeMello" <mdemello / kennel.ruf.rice.edu> wrote in message
> news:9ekcd7$jj0$1 / joe.rice.edu...
  >> 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]
  >>
  >> Is this possible? Already existing? Possible, but ugly? 'RTFM' is fine,
  >> as long as you tell me which FM to R :)

> Why don't you use map!

> a.map! {|i| i+1}

map! sets the iterated-over value to the retval of the block, not to the
value the yielded variable has when the block exits. I was wondering if a
more 'reference'-like technique were possible, where |i| was set not to a
local variable but an alias/reference/whatever to the actual object passed
in.

-- 
Martin DeMello