From: ara.t.howard@... Date: 2006-07-28T23:07:06+09:00 Subject: Re: Creating hashes with duplicate keys On Fri, 28 Jul 2006, 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? use rbtree (from the raa) harp:~ > cat a.rb require 'rbtree' rb = RBTree.new rb[1] = 'test' rb[2] = 'test' rb.each{|k,v| p [k,v]} harp:~ > ruby a.rb [1, "test"] [2, "test"] regards. -a -- we can never obtain peace in the outer world until we make peace with ourselves. - h.h. the 14th dali lama