From: Robert Klemme Date: 2007-12-14T17:24:52+09:00 Subject: Re: suprised by destructive map (not map!) 2007/12/13, Boris Schmid : > Thanks for clarifying that. I'll compile a list of destructive methods > for myself, and be aware of them when I map. > > Also learned not to trust blindly in the ! from another post. You should also remember that all parameters are passed by reference*. Whether hazard occurs depends on what you do with them, especially the mutable ones. In your case elements in your Array were Arrays which are mutable. The issue does not happen if you used integers instead - even with <<: irb(main):001:0> a1 = [1,2] => [1, 2] irb(main):002:0> a2 = a1.map {|x| x << 1} => [2, 4] irb(main):003:0> a1 => [1, 2] * Note: this is not 100% correct implementation wise but describes the situation properly from a Ruby user's point of view. Kind regards robert -- use.inject do |as, often| as.you_can - without end