From: "jeremyevans0 (Jeremy Evans)" Date: 2012-09-12T03:48:46+09:00 Subject: [ruby-core:47475] [ruby-trunk - Feature #7006] Add Enumerable#grouped_in as a each_slice without the block Issue #7006 has been updated by jeremyevans0 (Jeremy Evans). This should work: a = [1, 2, 3, 4].each_slice(2).to_a I don't see a reason to create another method to do this. ---------------------------------------- Feature #7006: Add Enumerable#grouped_in as a each_slice without the block https://bugs.ruby-lang.org/issues/7006#change-29248 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Open Priority: Normal Assignee: Category: lib Target version: 2.0.0 I'd like to transform [1, 2, 3, 4] into [[1, 2], [3, 4]]. Currently I can use something like: a = []; [1, 2, 3, 4].each_slice(2){|chunk| a << chunk} But I'd prefer to write just: a = [1, 2, 3, 4].grouped_in(2) Or any other method name you would choose, like "slices" or something else. -- http://bugs.ruby-lang.org/