From: "Iñaki Baz Castillo" Date: 2011-04-15T22:14:21+09:00 Subject: Re: Get the real object in a Hash key 2011/4/15 Robert Klemme : > On Fri, Apr 15, 2011 at 2:50 PM, Iñaki Baz Castillo wrote: >> However I've realized right now that it's not possible. The hash key >> doesn't store the given key as a reference to such object: > > This is a special optimization for unfrozen Strings as Hash keys. Oopss, if I freeze the string before inserting it as Hash key it doesn't occur (I get some object_id) :) Same occurs if I use a class inheriting from String. Good to know! Then I come back to my original question: ---------------- k1 = "aaa" k1.freeze h = {} h[k1] = "HELLO" ---------------- 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. Thanks a lot. -- Iñaki Baz Castillo