From: "Iñaki Baz Castillo" Date: 2011-04-15T23:46:27+09:00 Subject: Re: Get the real object in a Hash key 2011/4/15 Robert Klemme : >> Given a string "aaa", how can I get the object k1 from the hash? (I >> mean without comparing String#eql? each key with the string "aaa") >> Unfortunatelly I think Hash class does not provide a method for it. > > Exactly.  And you don't want to do it.  A Hash is an associative > storage which associates the value with your key.  If you need to > stuff in more information - you need to add it to the value and not > the key.  The simplest would be to define a Struct, e.g. > > Value = Struct.new :name, :val > > Then put this into the Hash as values > > h[k1] = Value["a name", "HELLO"] Yes, that seems a good solution. Thanks. -- Iñaki Baz Castillo