Actions
Feature #19177
closedoptional offset for Array#index
Status:
Closed
Assignee:
-
Target version:
-
Description
String#index allows an optional offset:
"the quick brown fox jumps over the lazy dog".index("the") #=> 0
"the quick brown fox jumps over the lazy dog".index("the",1) #=> 31
I was a bit surprised that Array doesn't support this and I feel it would be a very natural addition:
%w[the quick brown fox jumps over the lazy dog].index("the") #=> 0
%w[the quick brown fox jumps over the lazy dog].index("the",1) #=> 6 instead of ArgumentError
Updated by Dan0042 (Daniel DeLorme) almost 2 years ago
Oops, sorry, duplicate of #17056, which has a PR and was accepted but... never merged?
Updated by byroot (Jean Boussier) almost 2 years ago
- Related to Feature #17056: Array#index: Allow specifying the position to start search as in String#index added
Updated by byroot (Jean Boussier) almost 2 years ago
- Status changed from Open to Closed
Closing as duplicate.
@Dan0042 (Daniel DeLorme) can you revive the previous issue? The principle was accepted indeed, but it seems there was still a few open questions.
It's probably a bit late for 3.2, but would be worth trying to get this revived in January.
Actions
Like0
Like0Like0Like0