Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail From: Kevin Mahler Newsgroups: comp.lang.ruby Subject: Re: Get the real object in a Hash key Date: Fri, 15 Apr 2011 12:39:15 -0500 Organization: Service de news de lacave.net Lines: 35 Message-ID: References: NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1302890016 30000 65.111.164.187 (15 Apr 2011 17:53:36 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Fri, 15 Apr 2011 17:53:36 +0000 (UTC) In-Reply-To: X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 381652 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:2959 Robert K. wrote in post #993026: > 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). You said "And you don't want to do it." In fact doing it has its uses. Mutable keys or not is totally irrelevant, especially when the data was there before the hash was introduced, as in the original example. *Of course* making repeated calls to Hash#assoc in order to update stuff in the key would be stupid. That goes without saying. What would the purpose of the hash be? If that was your only point then we agree, although it was a vacuous point. Also do you realize that an example tends to stand for something which is not literally the example itself? He has a key. It contains some data. It's not necessarily true that he should duplicate that data in the mapped-to values. Mutable or not is beside the point. I notice this phenomenon a lot: undergeneralization. The String stands for something. It's his key data. If it were a simple value then the example wouldn't make sense in the first place. Gee, thanks for telling us that we shouldn't stuff random shit into a simple value and then use that as a hash key, whereupon we can't look up stuff in the hash directly but must use Hash#assoc instead. Again, if that was your point then we agree, albeit in the obvious and nearly information-free sense. I'm sure we would also agree that cats would be a poor building material for helicopters. -- Posted via http://www.ruby-forum.com/.