From: 7stud -- Newsgroups: comp.lang.ruby Subject: Re: Calling to_enum on a MatchData object Date: Sat, 9 Apr 2011 17:17:09 -0500 Organization: Service de news de lacave.net Lines: 26 Message-ID: <9c1c8032cd68837519fae5f3e1d22028@ruby-forum.com> References: <840b7dcf34f7c1ae6b2b9d80a6b55b69@ruby-forum.com> <0BEAEB78-76E6-4C9F-9EFD-55593D99E939@mac.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1302387638 11515 65.111.164.187 (9 Apr 2011 22:20:38 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Sat, 9 Apr 2011 22:20:38 +0000 (UTC) In-Reply-To: <0BEAEB78-76E6-4C9F-9EFD-55593D99E939@mac.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: 381254 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <9c1c8032cd68837519fae5f3e1d22028@ruby-forum.com> Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.stben.net!talisker.lacave.net!lacave.net!not-for-mail Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:2589 Gary Wright wrote in post #991944: > On Apr 9, 2011, at 8:03 AM, Vahagn Hayrapetyan wrote: >> e = file.enum_for(:each) #just the default >> e.each do |entry| #now the enumerator works >> puts entry >> end >> >> end >> end >> end > > > You are doing lots of unnecessary work there. Since MatchData#captures > returns an array and Array already defines each, you don't need to > create > any enumerator at all to iterate through the #captures array: > As the op said: >>> This is what I've done just to >>> experiment: -- Posted via http://www.ruby-forum.com/.