From: Trans Date: 2005-07-29T07:01:02+09:00 Subject: Re: Method Scope (again b/c google groups lost it) Ara.T.Howard wrote: > harp:~ > cat a.rb > class Dispatch < Hash > def method_missing(m, *a, &b); self[m].call(*a, &b); end > end > class String > def format(*a, &b) > Dispatch[ > :jumble => lambda{ 'jumble' }, > :bumble => lambda{ 'bumble' }, > ] > end > end > > p "Wizard".format.jumble > p "Wizard".format.bumble > > > harp:~ > ruby a.rb > "jumble" > "bumble" > > easy cheasy. ;-) Cleverly done. Certainly reduces the overhaed to an acceptable level. Too bad it looses all the goodness of OOP inheritence though. Thanks, T.