Module: Enumerable

Defined in:
lib/crawdad/compatibility.rb

Instance Method Summary collapse

Instance Method Details

#find_index(needle = nil, &b) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/crawdad/compatibility.rb', line 3

def find_index(needle=nil, &b)
  each_with_index do |hay, i|
    if b ? b[hay] : needle == hay
      return i
    end
  end
  nil
end