Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2744
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail |
|---|---|
| From | Vahagn Hayrapetyan <vahagnh@gmail.com> |
| Newsgroups | comp.lang.ruby |
| Subject | Re: Calling to_enum on a MatchData object |
| Date | Wed, 13 Apr 2011 06:14:29 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 34 |
| Message-ID | <344464c2400147e5f1dae39f855a89b7@ruby-forum.com> (permalink) |
| References | <840b7dcf34f7c1ae6b2b9d80a6b55b69@ruby-forum.com> <e6e43a5fecbaa1960938d453c77314ee@ruby-forum.com> <b5660160be5954fca0117643f7dcb9f1@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 1302693287 64111 65.111.164.187 (13 Apr 2011 11:14:47 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Wed, 13 Apr 2011 11:14:47 +0000 (UTC) |
| In-Reply-To | <b5660160be5954fca0117643f7dcb9f1@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 | 381411 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <344464c2400147e5f1dae39f855a89b7@ruby-forum.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:2744 |
Show key headers only | View raw
Hi,
> I'm not sure what you are referring to because each() is neither defined
> nor inherited in the MatchData class. Check the output of:
>
> md = /h/.match('hello')
> puts md.methods.sort
>
> And Enumerator defines its own each() method.
Sorry - I meant to say "enum_for / to_enum" was inherited and had to be
ferreted out. The reason why I made this mistake is because of this:
o = Object.new
e = o.enum_for #No argument given, so :each is implied. No errors!
e.next #NoMethodError: undefined method `each' for #<Object:0x12ed00>
o.respond_to?(:each) #false. Aha!
My confusion with this stems from line 2 above - that you can define a
method using a non-existent method as default argument and not get any
error message as a consequence of that. But hey - "Ruby is dynamic and
so is human nature", so I think I am going to like this behavior anyway.
> You may be confusing Enumer-ator with something you read about
> Enumer-able.
Exactly! I was mixing them up with regards to "each" and "yield". "The
Well-Grounded Rubyist" is a great book though.
Thanks again for your help - your examples are excellent.
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Calling to_enum on a MatchData object Vahagn Hayrapetyan <vahagnh@gmail.com> - 2011-04-08 13:19 -0500
Re: Calling to_enum on a MatchData object 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-08 14:41 -0500
Re: Calling to_enum on a MatchData object 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-08 14:21 -0500
Re: Calling to_enum on a MatchData object 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-08 20:09 -0500
Re: Calling to_enum on a MatchData object Vahagn Hayrapetyan <vahagnh@gmail.com> - 2011-04-09 07:03 -0500
Re: Calling to_enum on a MatchData object 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-09 13:18 -0500
Re: Calling to_enum on a MatchData object Vahagn Hayrapetyan <vahagnh@gmail.com> - 2011-04-13 06:14 -0500
Re: Calling to_enum on a MatchData object Gary Wright <gwtmp01@mac.com> - 2011-04-09 14:25 -0500
Re: Calling to_enum on a MatchData object 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-09 17:17 -0500
Re: Calling to_enum on a MatchData object Vahagn Hayrapetyan <vahagnh@gmail.com> - 2011-04-13 06:28 -0500
Re: Calling to_enum on a MatchData object Gary Wright <gwtmp01@mac.com> - 2011-04-13 22:44 -0500
Re: Calling to_enum on a MatchData object 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-09 14:02 -0500
Re: Calling to_enum on a MatchData object Robert Klemme <shortcutter@googlemail.com> - 2011-04-13 06:45 -0500
Re: Calling to_enum on a MatchData object Vahagn Hayrapetyan <vahagnh@gmail.com> - 2011-04-14 11:13 -0500
Re: Calling to_enum on a MatchData object Vahagn Hayrapetyan <vahagnh@gmail.com> - 2011-04-13 06:25 -0500
csiph-web