Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/assert2/rubynode_reflector.rb

Instance Method Summary collapse

Instance Method Details

#in_groups_of(number, fill_with = nil, &block) ⇒ Object



851
852
853
854
855
856
# File 'lib/assert2/rubynode_reflector.rb', line 851

def in_groups_of(number, fill_with = nil, &block)
  require 'enumerator'
  collection = dup
  collection << fill_with until collection.size.modulo(number).zero?
  collection.each_slice(number, &block)
end