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 ablock
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.3I got the same thing as Loic on 2.2.3
Post a comment