From: dblack@... Date: 2006-08-22T03:12:12+09:00 Subject: Re: Why Does Hash Apparently Reorder Its Internal Representation And Other Associated Ponderings Hi -- On Tue, 22 Aug 2006, Just Another Victim of the Ambient Morality wrote: > > "Martin DeMello" wrote in message > news:f93a6bcc0608210510j438b2d58l1d485c707810f571@mail.gmail.com... >> On 8/21/06, Bil Kleb wrote: >>> Martin DeMello wrote: >>>> On 8/21/06, Bil Kleb wrote: >>>> >>>> You can do this automatically (if you aren't already) by creating an >>>> object that holds a hash and an array, defines []=, each and delete to >>>> do the right thing, and delegates missing methods to the hash. >>> >>> Hmmm... good idea. I've largely missed out on the >>> whole method_missing idiom. Sounds like a good use. >>> >>> I'll try to look into it after I return from JPL next >>> week. However, if you'd like to throw down an example, >>> I might be able to work it in now... >> >> Quick proof of concept: >> >> require 'enumerator' >> >> class OHash >> include Enumerable >> >> ... >> >> def method_missing(*args) >> @h.send(*args) >> end >> end > > Is there a reason why you don't simply inheret from Hash, or is this > just another one of those There's More Than One Way To Do It scenarios? You mean TMTOTMTOWTDIS? :-) David -- http://www.rubypowerandlight.com => Ruby/Rails training & consultancy ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <----- http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log http://www.manning.com/black => book, Ruby for Rails http://www.rubycentral.org => Ruby Central, Inc.