From: Sammy Larbi Date: 2007-07-19T00:01:04+09:00 Subject: Re: Are we cool? method_missing in enumerator I might test that it can still throw missing method exception if the called method isn't supposed to be doing what you're making it do (ie, perhaps it was a typo) Sam Trans wrote, On 7/17/2007 9:01 AM: > Can anyone demonstrate problems with the following? > > # Adds immediate elementwise ability to Enumerator. > # Any non-enumeration method is passed on to each. > # > # [1,2,3].to_enum(:map) + 3 > # => [4,5,6] > # > # Note there may be a few essential methods this can not > # be used on, such as #object_id. > > class Enumerable::Enumerator > def method_missing(sym,*args,&blk) > each{ |x| x.send(sym,*args,&blk) } > end > end > > I like the simplicity of this and would rather use it than add an > another class layer, but I need to be sure I'm not overlooking any > potential dangers with doing so. > > Thanks, > T. > > > > >