From: Florian Gilcher Date: 2012-05-07T23:26:21+09:00 Subject: Re: Why Enumerator#next does not return more than one value? On May 7, 2012, at 3:10 PM, Földes László wrote: > If I have an Enumerator which yields elements of a mathematical series > (logistic map), I can use: > > enum.first(10) to get the first 10 value, > enum.next to get the next values, > > but there is no enum.next(10) to get the next 10 values. > I do some trickery like this to achieve the same result (because I need > the result in an Array, as #first returns it): > (0..20).map {(lm.next)} > > Is there a nicer way to do it? (Or did I overlook some existing method > in Enumerable?) > > At first I thought it is logical that #next should have a parameter so > the #first(10) method could be actually a #rewind + #next(10). This is what #take does: http://www.ruby-doc.org/core-1.9.3/Enumerator.html has an example in the docs of #new.