15 Dec
2025
15 Dec
'25
10:35 a.m.
Issue #21678 has been updated by etienne (Étienne Barrié). Should we alias `detect` to also use that Array-specific faster implementation? ```console
[].method :detect => #<Method: Array(Enumerable)#detect(*)> [].method :find => #<Method: Array#find(*)>
----------------------------------------
Feature #21678: Enumerable#rfind
https://bugs.ruby-lang.org/issues/21678#change-115679
* Author: kddnewton (Kevin Newton)
* Status: Closed
----------------------------------------
I'd like to introduce `rfind` to enumerable, which would effectively be the same as `reverse_each.find`. I've found myself using this a surprising number of times, and have been surprised at its omission. That means either falling back to `reverse_each` or `rindex`.
For context, here are a couple of examples of this in the wild:
* [pry](https://github.com/pry/pry/blob/80816f596774d00afdc81a555724b0819bf26782/lib/pry/commands/edit.rb#L213)
* [bundler](https://github.com/ruby/rubygems/blob/e4fd4ee3fad005fce1dbcbeffd47e7199243bc42/bundler/lib/bundler/self_manager.rb#L146)
* [textbringer](https://github.com/shugo/textbringer/blob/738d318558045efc9d978e6b5616d2641a1b1305/lib/textbringer/modes/ruby_mode.rb#L271)
--
https://bugs.ruby-lang.org/