Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #3202
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail |
|---|---|
| From | Joey Zhou <yimutang@gmail.com> |
| Newsgroups | comp.lang.ruby |
| Subject | Re: How to use Enumerator::Generator in Ruby 1.9.2 |
| Date | Tue, 19 Apr 2011 21:23:57 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 26 |
| Message-ID | <4dd610eb5a6ed8425c11236449c7a032@ruby-forum.com> (permalink) |
| References | <9bf8d8ed06528ddc8ebda9e54b79e232@ruby-forum.com> |
| NNTP-Posting-Host | bristol.highgroove.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | talisker.lacave.net 1303266269 17701 65.111.164.187 (20 Apr 2011 02:24:29 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Wed, 20 Apr 2011 02:24:29 +0000 (UTC) |
| In-Reply-To | <9bf8d8ed06528ddc8ebda9e54b79e232@ruby-forum.com> |
| X-Received-From | This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway |
| X-Mail-Count | 381883 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <4dd610eb5a6ed8425c11236449c7a032@ruby-forum.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:3202 |
Show key headers only | View raw
May I think like this, Enumerator.new is a short way, including two
steps:
eg = Enumerator::Generator.new {|y| y << 1 }
p eg # #<Enumerator::Generator:0xb44890>
e1 = Enumerator.new(eg)
p e1 # #<Enumerator: #<Enumerator::Generator:0xb44890>:each>
e2 = eg.to_enum
p e2 # #<Enumerator: #<Enumerator::Generator:0xb44890>:each>
so ruby-doc says there are two forms of Enumerator.new:
Enumerator.new(obj, method = :each, *args)
Enumerator.new { |y| ... }
in fact, there's just one, the second one can be regarded as
Enumerator.new(enum_generator_instance)
Does Enumerator::Generator exist, because Ruby 1.8 has a Generator
class?
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Find similar | Unroll 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