From: Paul Dugdale
Date: 2008-05-14T00:46:22+09:00
Subject: Re: Updating all values in a Hash
Sorry! I was trying to keep my post simple, but ended up doing a really
bad job of explaining what I was trying to achieve...
I come from a C programming background, so I'm always thinking in terms
of pass-by-value and pass-by-reference.
What I was trying to find out is - is there any way of passing a
reference to the value to the 'each' block, rather than a copy of the
value.
I.e. some easy way of doing this:
hash.each { |k,v| v = my_value }
Without having to refer to the hash again in the block like this:
hash.each { |k,v| hash[k] = my_value }
--
Posted via http://www.ruby-forum.com/.