Class: Array

Inherits:
Object show all
Defined in:
lib/aastdlib/array.rb

Instance Method Summary collapse

Instance Method Details

#indices(value) ⇒ Object

Accepts a value that is check against each element in the array itself and returns a new array containing the index for each matching element.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/aastdlib/array.rb', line 6

def indices(value)
  counter = 0
  indices = []

  self.each do |v|
    indices << counter if value == v
    counter+=1
  end

  return indices

end