Method: Array#index

Defined in:
lib/core/facets/array/index.rb

#index(obj = nil, &block) ⇒ Object

Allows #index to accept a block.

['a', 'b', 'c'].index{ |x| x.upcase == 'C' } #=> 2

IMPORTANT: This is one of the few core overrides in Facets.



12
13
14
15
16
17
18
# File 'lib/core/facets/array/index.rb', line 12

def index(obj=nil, &block)
  if block_given?
    _facets_index(find(&block))
  else
    _facets_index(obj)
  end
end