From: Rick DeNatale Date: 2008-07-08T04:51:55+09:00 Subject: Re: implementing a simple and efficient index system ------=_Part_1576_13009916.1215460535785 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Mon, Jul 7, 2008 at 3:12 AM, Robert Dober wrote: > > > > Thanks, that's exactly what I was looking for! I didn't know set > > basically works like a hash without a key... > > make that "without a value". > Which makes an interesting contrast between Ruby and Smalltalk. In Smalltalk-80 Set is the more "fundamental" class, the implementation uses hashing to ensure that duplicates are eliminated and to speed up the test of whether or not a Set contains a given element. Smalltalks equivalent to Hash, the Dictionary class, is implemented (via inheritance) as a Set of association objects, where an association represents a key value pair, and where two associations are equal if the keys are equal, and the hash of the association is the hash of the key. Ruby on the other hand implements Set as a Hash where the values are unimportant, and does this via delegating to a hash rather than via inheritance. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ ------=_Part_1576_13009916.1215460535785--