"David Vlad" <cluny_gisslaren / hotmail.com> wrote in message news:3294e69df66809dc8d911d8a5bb2fa09 / ruby-forum.com... > Im so sorry, I have misunderstood everything. I thought it was supposed > to modify the array not create a new one within the block. > > Is there any method that actually does modify the array or will I have > to do something like this: > > array = [1,3,7,8] > i = 0 > > while i < array.length > array[i] = array[i] * 2 > i += 1 > end > -- > Posted via http://www.ruby-forum.com/. > use: array.collect! { ... } or array.map! { ... } array = [1,3,7,8] array.collect! { |x| x*2 } # => [2,6,14,16] hth gfb