From: Farrel Lifson Date: 2006-07-28T17:48:44+09:00 Subject: Re: Creating hashes with duplicate keys On 28/07/06, Sy Ali wrote: > I want to simplify this hash creation: > g = { 1 => "test", 2 => "test", } > > I have a particularly complicated hash that I'm generating. It can > have very large values. > > Right now, I duplicate values with something like this: > > c = { 1 => "one", } > d = { 2 => c[1], } > c.merge!(d) > > however, I don't like the way my code looks.. I want to be able to > specify the duplication within the hash generation. > > Is this possible? Something like this? irb(main):001:0> c={} => {} irb(main):002:0> c[1] = "one" => "one" irb(main):003:0> c[2] = c[1] => "one" irb(main):004:0> c[1].object_id == c[2].object_id => true Farrel