method

rindex

v1_9_3_125 - Show latest stable - Class: Array
rindex(p1)
public

Returns the index of the last object in self

to obj. If a block is given instead of an

argument, returns index of first object for which block is true, starting from the last object. Returns nil if no match is found. See also Array#index.

If neither block nor argument is given, an enumerator is returned instead.

a = [ "a", "b", "b", "b", "c" ]
a.rindex("b")        #=> 3
a.rindex("z")        #=> nil
a.rindex{|x|x=="b"}  #=> 3

1Note

rindex with identically array elements

sld7700 ยท May 26, 2012

=== Code Example a = [1,1,1] a.rindex( a.min ) #=> 2