From: Martin DeMello Date: 2002-11-20T05:50:44+09:00 Subject: Re: Thoughts on generators Nat Pryce wrote: > If the behaviour of SimpleGenerator.new(a) depends on the type of a -- > e.g. is polymorphic with respect to a -- then it should really be a > method defined by a. > > E.g. your example would be reformulated as: > > g = a.generator > i = g.next Right you are. Something like class Range def generator RangeGenerator.new(self) end end for each class, or is there a better way to do it? One problem though is that this doesn't let us create generators for arbitrary classes (frinstance, anything that supports self[int] could yield a generator), but I could keep SimpleGenerator.new around as well. martin