This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.

index

        # Array.index

(from ruby core)
---
    index(*args)

---

Returns the index of a specified element.

When argument `object` is given but no block, returns the index of the
first element `element` for which `object == element`:
    a = [:foo, 'bar', 2, 'bar']
    a.index('bar') # => 1

Returns `nil` if no such element found.

When both argument `object` and a block are given, calls the block with
each successive element; returns the index of the first element for
which the block returns a truthy value:
    a = [:foo, 'bar', 2, 'bar']
    a.index {|element| element == 'bar' } # => 1

Returns `nil` if the block never returns a truthy value.

When neither an argument nor a block is given, returns a new Enumerator:
    a = [:foo, 'bar', 2]
    e = a.index
    e # => #<Enumerator: [:foo, "bar", 2]:index>
    e.each {|element| element == 'bar' } # => 1

Array#find_index is an alias for Array#index.

Related: #rindex.


(This method is an alias for Array#find_index.)

Returns the index of a specified element.

When argument `object` is given but no block, returns the index of the
first element `element` for which `object == element`:
    a = [:foo, 'bar', 2, 'bar']
    a.index('bar') # => 1

Returns `nil` if no such element found.

When both argument `object` and a block are given, calls the block with
each successive element; returns the index of the first element for
which the block returns a truthy value:
    a = [:foo, 'bar', 2, 'bar']
    a.index {|element| element == 'bar' } # => 1

Returns `nil` if the block never returns a truthy value.

When neither an argument nor a block is given, returns a new Enumerator:
    a = [:foo, 'bar', 2]
    e = a.index
    e # => #<Enumerator: [:foo, "bar", 2]:index>
    e.each {|element| element == 'bar' } # => 1

Array#find_index is an alias for Array#index.

Related: #rindex.



      

This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.