Project

General

Profile

ActionsLike0

Feature #19177

closed

optional offset for Array#index

Added by Dan0042 (Daniel DeLorme) over 2 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:111181]

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

Related issues 1 (1 open0 closed)

Related to Ruby - Feature #17056: Array#index: Allow specifying the position to start search as in String#indexOpenActions
#2

Updated by byroot (Jean Boussier) over 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) over 2 years ago

  • Status changed from Open to Closed
ActionsLike0

Also available in: Atom PDF