2011/4/15 Robert Klemme <shortcutter / googlemail.com>:
> On Fri, Apr 15, 2011 at 2:50 PM, Iaki Baz Castillo <ibc / aliax.net> 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.

-- 
Iaki Baz Castillo
<ibc / aliax.net>