RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Slicing and Dicing Ruby Enumerables

Have you ever needed to group items in an array, or lines in a file? In this post we’ll discuss a few often-overlooked Enumerable methods that let you do just that. http://blog.honeybadger.io/ruby-enumerable-slicing-before-when-and-after/

Comments

I believe your slice_before example with a block should output [[1], [2, 3], [4, 5]] not [[1, 2], [3, 4, 5]]. At least that’s the behaviour I got on my local machine with ruby 1.9.3 and 2.2.3

I got the same thing as Loic on 2.2.3

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in