From: raja@... (Raja Sooriamurthi) Date: 2001-03-07T06:40:02+09:00 Subject: [ruby-talk:12184] Re: disassembling and reassembling a hash Stephen White writes: >On Wed, 7 Mar 2001, Raja S. wrote: >> I didn't want to go "downwards" in terms of creating a sub-class of Hash >> but didn't occur to me that one could go "upwards" and create an anonymous >> super-class! Very nice and very clever! Thank you. > Why are you avoiding making a sub-class of Hash? Primarily a personal choice (aesthetics, name space polution). We could: say: class MyHash < Hash ... end and override #new in MyHash with delegation via #super. But for all practical purposes MyHash objects would be identical to Hash objects in terms of features/functionality --- nothing more nothing less. The only difference being how MyHash objects were created (from an array of keys and values). Introducing a new class just because these objects are created different would be gratuitous. A creator method like Hash.make would be better. My personal preference would be to extend the functionality of Hash.new . Raja