From: David Alan Black Date: 2001-11-30T22:46:14+09:00 Subject: [ruby-talk:27064] Re: Using Enumerable Hi -- On Fri, 30 Nov 2001, Peter Hickman wrote: > Thanks to all who replied, like all ruby it was alot simpler than I > thought. > > class Fred > include Enumerable > > def initialize > @end = 10 > @pointer = 0 > end > > def each > while @pointer != @end do > @pointer += 1 > yield @pointer > end > @pointer = 0 > end > end And if you want to be even more concise while still (in my opinion :-) being readable: def each yield @pointer += 1 until @pointer == @end @pointer = 0 end David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav