16 Mar '12, 11pm

A use of Enumerable#chunk

drbrain | Fri, 16 Mar 2012 23:19:07 GMT Posted in Ruby In Ruby 1.9, Enumerable has a few new methods including Enumerable#chunk (which was added for 1.9.2). The #chunk method walks your Enumerable and divides it into chunks based on a selecting block. Unlike Enumerable#partition, the chunks are returned in-order. Here's an example from the documentation: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5].chunk { |n| n.even? }.each { |even, ary| p [even, ary] } #=> [false, [3, 1]] # [true, [4]] # [false, [1, 5, 9]] # [true, [2, 6]] # [false, [5, 3, 5]] When I first saw this method I thought, "this looks like a useful method… but how?" I'm working on bringing Markdown support to RDoc and the last remaining base Markdown feature I need to support is a hard break due to two spaces at the end of a line in a paragraph. For background, RDoc parses various formats into a common syntax tree which i...

Full article: http://blog.segment7.net/2012/03/16/a-use-of-enumerable-c...

Tweets

and that's why you always use parentheses!

and that's why you always use parentheses!

robots.thoughtbot.com 19 Mar '12, 2pm

March 19, 2012 Tagged: ruby shoulda Comments (View) Do End Your Braces Braces and do /end are completely swappable—almost ...

webinar

element14.com 24 Mar '12, 10pm

ali

ali

seomoz.org 25 Mar '12, 7am

Have a look at your site and decide where it is this tactic could be useful. Ideally, users will be very close to interact...

Think before you use water - do you really need...

environment-agency.gov.uk 28 Mar '12, 2pm

Current water status Current water restrictions (including hosepipe bans) Find out why you should save water and how you c...

@clairejoey Sorry. Thought you were a spambot :...

wordtracker.com 18 Mar '12, 1am

Ken McGaffin is Chief Marketing Officer at Wordtracker. He is an experienced internet marketing consultant and has worked ...

tb-0.5 を release した。http://t.co/Pvd9Leuf melt と...

rubygems.org 29 Mar '12, 12pm

tb is a manipulation tool for table: CSV, TSV, JSON, etc. tb provides a command and a library for manipulating tables: Uni...

ウクライナからの中古ですか。

defencetalk.com 21 Mar '12, 12am

The future of the Russian military General African Defense discussion emotional intelligence in army USAF R-11 Refueler Tr...

Agency Use of New Media, and More from CRS: Som...

fas.org 19 Mar '12, 12pm

« US Soldiers Are Immune from Afghan Prosecution, CRS Says Nozette Was Manipulated by FBI, His Attorneys Say » Agency Use ...

How To Use Memes to Build EASY Backlinks & Traffic

seomoz.org 15 Mar '12, 4pm

I'm going to play Devil's Advocate here for a little bit and offer some advice of my own. I've been on Reddit since its la...