Actions
Feature #21678
openEnumerable#rfind
Feature #21678:
Enumerable#rfind
Status:
Open
Assignee:
-
Target version:
-
Description
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:
Updated by matz (Yukihiro Matsumoto) 19 days ago
The Enumerable module basically relies on the #each method which only works in the forward direction, and the only way to scan backwards is to convert it to an array once. I agree with Array#rfind (which can be implemented efficiently), but is it necessary for the Enumerable module as well?
Matz.
Updated by kddnewton (Kevin Newton) 19 days ago
That makes sense! I'm totally fine with it just being on Array.
Actions