diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/array.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/array.rb b/activesupport/lib/active_support/core_ext/array.rb index db6f5587da..243aeab423 100644 --- a/activesupport/lib/active_support/core_ext/array.rb +++ b/activesupport/lib/active_support/core_ext/array.rb @@ -16,7 +16,11 @@ class Array #:nodoc: require 'enumerator' collection = dup collection << fill_with until collection.size.modulo(number).zero? - collection.each_slice(number, &block) + grouped_collection = [] unless block_given? + collection.each_slice(number) do |group| + block_given? ? yield(group) : grouped_collection << group + end + grouped_collection unless block_given? end # Divide the array into one or more subarrays based on a delimiting +value+ |