From: lasitha Date: 2009-03-12T16:10:42+09:00 Subject: Re: change (and update) values of hash On Thu, Mar 12, 2009 at 12:06 PM, Jason Lillywhite wrote: > >> This is much easier: >> h.each {|k, v| h[k] = v * 2 } > > thank you. > > I was told it could be bad to change values during iteration. That is > why I proposed doing replace. what do you think? There was a recent thread about this: http://www.nabble.com/Iterating-a-changing-Hash-under-1.9.1-td22023417.html I believe assigning values to existing keys is safe. If in doubt, iterate over the keys instead: h.keys.each {|k| h[k] = h[v] * 2 } solidarity, lasitha.