Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail From: Johannes Held Newsgroups: comp.lang.ruby Subject: Re: How to use Enumerator::Generator in Ruby 1.9.2 Date: Tue, 19 Apr 2011 12:55:01 +0200 Lines: 18 Message-ID: <9157vaFtmrU1@mid.dfncis.de> References: <9bf8d8ed06528ddc8ebda9e54b79e232@ruby-forum.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.dfncis.de Lbg0JVq/MNNOmSaSMYnovgTwgxyy+kzlvEbqnvc7tHIL36 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3157 On 19.04.2011 09:44, Robert Klemme wrote: > You can see an example in a recent posting: > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/381414 But this can be achieved easier, as e.g. (0..9).cycle already returns an Enumerator. ruby-1.9.2-p136 :002 > foo = (0..9).cycle => # ruby-1.9.2-p136 :003 > foo.next => 0 ruby-1.9.2-p136 :004 > foo.take 12 => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1] ruby-1.9.2-p136 :005 > foo.next => 1 ruby-1.9.2-p136 :006 > -- Gruß, Johannes