[DOC] Tweaks for Array#rindex

This commit is contained in:
BurdetteLamar 2024-10-09 12:33:19 -05:00 committed by Peter Zhu
parent 1962be267c
commit f7fdf6cc36
Notes: git 2024-10-09 18:05:42 +00:00

19
array.c
View File

@ -2129,20 +2129,20 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)
/* /*
* call-seq: * call-seq:
* array.rindex(object) -> integer or nil * rindex(object) -> integer or nil
* array.rindex {|element| ... } -> integer or nil * rindex {|element| ... } -> integer or nil
* array.rindex -> new_enumerator * rindex -> new_enumerator
* *
* Returns the index of the last element for which <tt>object == element</tt>. * 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 = [:foo, 'bar', 2, 'bar']
* a.rindex('bar') # => 3 * a.rindex('bar') # => 3
* *
* Returns +nil+ if no such object found. * 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: * returns the index of the last element for which the block returns a truthy value:
* *
* a = [:foo, 'bar', 2, 'bar'] * a = [:foo, 'bar', 2, 'bar']
@ -2150,14 +2150,9 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)
* *
* Returns +nil+ if the block never returns a truthy value. * 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'] * Related: see {Methods for Querying}[rdoc-ref:Array@Methods+for+Querying].
* e = a.rindex
* e # => #<Enumerator: [:foo, "bar", 2, "bar"]:rindex>
* e.each {|element| element == 'bar' } # => 3
*
* Related: #index.
*/ */
static VALUE static VALUE