Method: Immutable::List#each_chunk

Defined in:
lib/immutable/list.rb

#each_chunk(number) {|list| ... } ⇒ self, Enumerator Also known as: each_slice

Split the items in this list in groups of number, and yield each group to the block (as a List). If no block is given, returns an Enumerator.

Yields:

  • (list)

    Once for each chunk.

Returns:

  • (self, Enumerator)


740
741
742
743
744
# File 'lib/immutable/list.rb', line 740

def each_chunk(number, &block)
  return enum_for(:each_chunk, number) unless block_given?
  chunk(number).each(&block)
  self
end