class Array
Public Instance Methods
find_all_indices() { |elem| ... }
click to toggle source
引数と等価な全て要素のインデックスからなる配列を返す。 find_all は要素を返すが、これはインデックスを返す点が異なる。 e.g., [ 10, 20, 30 ].find_all_indices{ |i| i < 25 } #=> [ 0, 1 ]
# File lib/maset/mapping.rb, line 6 def find_all_indices results = [] self.each_with_index do |elem, i| results << i if yield( elem ) end results end