From: Paul Mckibbin Date: 2009-04-22T07:57:25+09:00 Subject: Re: Is there a better way to do this? Robert Dober wrote: > On Tue, Apr 21, 2009 at 11:40 PM, Robert Klemme > wrote: >> data. �If you have classes already for storing all this, I'd probably write >>> or alternatively >>> >> def method_missing(sym,*args,&blk) >> �self[sym] || self[sym.to_s] || super > the following line will work for all potential hash values > > fetch( sym ) { fetch( sym.to_s ) { super } } > > HTH > Robert Cool and will generate the same error type, I've used a modification of it to make the stack look the same, and give a debugging hint if it does go wrong.... begin fetch( sym ) { fetch( sym.to_s ) { super }} rescue raise NoMethodError,"undefined method #{sym} for #{self.inspect}:#{self.class} overridden by Mac's redefinition of Hash::method_missing in #{__FILE__}" end Thanks again, Mac -- Posted via http://www.ruby-forum.com/.