On Fri, Apr 15, 2011 at 4:47 PM, Kevin Mahler <kevin.mahler / yahoo.com> wrote:
> Robert K. wrote in post #993000:
>> On Fri, Apr 15, 2011 at 3:14 PM, Iaki Baz Castillo <ibc / aliax.net>
>>> 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.           >> storage which associates the value with your key.   
>> stuff in more information - you need to add it to the value and not
>> the key....
>
> Well you may want to do it -- that's why Hash#assoc exists. Hash keys
> can be objects of any sort, and there are use cases for storing
> nonsimple keys.

I did not argue against complex keys.  The issue is with *mutable*
keys.  And since adding data to the key object is also associating
(which is done with the value as well) the most natural way would be
to place that additional information there.  Not to mention the
questionable approach to stuff something into what is usually
considered a simple value (String).

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/