Skip to content

Add Array#rindex - #471

Merged
tannevaled merged 1 commit into
mainfrom
feat/cluster41
Aug 27, 2026
Merged

tannevaled merged 1 commit into
mainfrom
feat/cluster41

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Array#rindex was missing entirely (core/array/rindex was all NoMethodError).
It now searches backward from the end:

  • rindex(obj) → the last index whose element == obj;
  • rindex { |e| … } → the last index whose block is truthy (an argument, when
    given, wins over the block, as MRI does);
  • no argument and no block → a sized Enumerator;
  • nil when nothing matches.

Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
ratchet floor rises 15820 → 15830 (core/array/rindex 0 → 9, zero regressions in
a deterministic per-file sweep).

🤖 Generated with Claude Code

Array#rindex was missing entirely. It now searches backward from the end:
rindex(obj) returns the last index whose element == obj; rindex { |e| … } the
last index whose block is truthy (an argument, when given, wins over the block,
as MRI does); and with no argument and no block it returns a sized Enumerator.
Returns nil when nothing matches.

Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
floor rises 15820 -> 15830 (core/array/rindex 0 -> 9).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit e116e2c into main Aug 27, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/cluster41 branch August 27, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant