Module: LLT::CoreExtensions::Array

Included in:
Array
Defined in:
lib/llt/core_extensions/array.rb

Instance Method Summary collapse

Instance Method Details

#each_overlapping_pairObject



10
11
12
13
14
15
16
17
# File 'lib/llt/core_extensions/array.rb', line 10

def each_overlapping_pair
  pairs = self[0..-2].zip(self[1..-1])
  if block_given?
    pairs.each { |pair| yield(pair) }
  else
    pairs.to_enum
  end
end

#select_indicesObject



4
5
6
7
8
# File 'lib/llt/core_extensions/array.rb', line 4

def select_indices
  indices = []
  each_with_index { |x, i| indices << i if yield(x) }
  indices
end