aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/array/grouping.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/grouping.rb b/activesupport/lib/active_support/core_ext/array/grouping.rb
index f79b100b3b..640e6e9328 100644
--- a/activesupport/lib/active_support/core_ext/array/grouping.rb
+++ b/activesupport/lib/active_support/core_ext/array/grouping.rb
@@ -58,7 +58,7 @@ class Array
# size / number gives minor group size;
# size % number gives how many objects need extra accommodation;
# each group hold either division or division + 1 items.
- division = size / number
+ division = size.div number
modulo = size % number
# create a new array avoiding dup
@@ -67,9 +67,9 @@ class Array
number.times do |index|
length = division + (modulo > 0 && modulo > index ? 1 : 0)
- padding = fill_with != false &&
- modulo > 0 && length == division ? 1 : 0
- groups << slice(start, length).concat([fill_with] * padding)
+ groups << last_group = slice(start, length)
+ last_group << fill_with if fill_with != false &&
+ modulo > 0 && length == division
start += length
end