Skip to content

Commit

Permalink
[DOC] Tweaks for Array#rindex
Browse files Browse the repository at this point in the history
  • Loading branch information
BurdetteLamar authored and peterzhu2118 committed Oct 9, 2024
1 parent 1962be2 commit f7fdf6c
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -2129,35 +2129,30 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)

/*
* call-seq:
* array.rindex(object) -> integer or nil
* array.rindex {|element| ... } -> integer or nil
* array.rindex -> new_enumerator
* rindex(object) -> integer or nil
* rindex {|element| ... } -> integer or nil
* rindex -> new_enumerator
*
* Returns the index of the last element for which <tt>object == element</tt>.
*
* When argument +object+ is given but no block, returns the index of the last such element found:
* With argument +object+ given, returns the index of the last such element found:
*
* a = [:foo, 'bar', 2, 'bar']
* a.rindex('bar') # => 3
*
* Returns +nil+ if no such object found.
*
* When a block is given but no argument, calls the block with each successive element;
* With a block given, calls the block with each successive element;
* returns the index of the last element for which the block returns a truthy value:
*
* a = [:foo, 'bar', 2, 'bar']
* a.rindex {|element| element == 'bar' } # => 3
*
* Returns +nil+ if the block never returns a truthy value.
*
* When neither an argument nor a block is given, returns a new Enumerator:
* When neither an argument nor a block is given, returns a new Enumerator.
*
* a = [:foo, 'bar', 2, 'bar']
* e = a.rindex
* e # => #<Enumerator: [:foo, "bar", 2, "bar"]:rindex>
* e.each {|element| element == 'bar' } # => 3
*
* Related: #index.
* Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
*/

static VALUE
Expand Down

0 comments on commit f7fdf6c

Please sign in to comment.