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
Actions
Like0
Like0Like0Like0