From: Gavin Sinclair Date: 2002-10-13T08:52:09+09:00 Subject: Re: Delegating each From: "Michael Schuerig" > > I have a class that basically encapsulates an array and mixes > Enumerable in. Currently it looks something like this > > class C > include Enumerable > ... > def each(&proc) > @myarray.each do |e| > proc.call(e) > end > end > end > > Is there a more direct way of implementing each? Is is possible to get > rid of the each-loop and delegate its behavior to myarray? > > Michael In addition to the other replies, you can check out the Delegate and SimpleDelegate classes. I haven't used these, so I can't help more, but these will be useful if you want to delegate other methods as well. Gavin