From: matz@... (Yukihiro Matsumoto) Date: 2001-09-04T17:09:08+09:00 Subject: [ruby-talk:20844] Re: modify hash during iteration Hi, In message "[ruby-talk:20840] modify hash during iteration" on 01/09/04, Tomas Brixi writes: |I have a question to following piece of code |----------------- |h = Hash.new |#assign some data | |h.each do |pair| | h[pair[0]] = new_value |end |----------------- | |is this the right way or are there better ways to do this It's OK to change the associated value to the existing key. In case you add new key during hash iteration, it may or may not appear in the iteration. But it shouldn't crash anyway. matz.