Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3157

Re: How to use Enumerator::Generator in Ruby 1.9.2

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 <johannes.held@informatik.uni-erlangen.de>
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> (permalink)
References <9bf8d8ed06528ddc8ebda9e54b79e232@ruby-forum.com> <BANLkTin_Ff6FnV6JcPQKQmfc0op_=0Hi7g@mail.gmail.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 <BANLkTin_Ff6FnV6JcPQKQmfc0op_=0Hi7g@mail.gmail.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:3157

Show key headers only | View raw


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
  => #<Enumerator: 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

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to use Enumerator::Generator in Ruby 1.9.2 Joey Zhou <yimutang@gmail.com> - 2011-04-19 01:43 -0500
  Re: How to use Enumerator::Generator in Ruby 1.9.2 Robert Klemme <shortcutter@googlemail.com> - 2011-04-19 02:44 -0500
    Re: How to use Enumerator::Generator in Ruby 1.9.2 Johannes Held <johannes.held@informatik.uni-erlangen.de> - 2011-04-19 12:55 +0200
      Re: How to use Enumerator::Generator in Ruby 1.9.2 Robert Klemme <shortcutter@googlemail.com> - 2011-04-19 07:01 -0500
  Re: How to use Enumerator::Generator in Ruby 1.9.2 Joey Zhou <yimutang@gmail.com> - 2011-04-19 07:49 -0500
    Re: How to use Enumerator::Generator in Ruby 1.9.2 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-19 12:36 -0500
  Re: How to use Enumerator::Generator in Ruby 1.9.2 Joey Zhou <yimutang@gmail.com> - 2011-04-19 21:23 -0500

csiph-web