Actions
Feature #13118
closedArray#at(*indexes); Array#at([indexes])
Status:
Closed
Assignee:
-
Target version:
-
Description
It is useful to have Array return a repeated permutation. Rather than add another method, we could overload Array#at to take multiple indexes.
a = [ "a", "b", "c", "d", "e" ]
a.at(0) #=> "a"
a.at(-1) #=> "e"
#New stuff
a.at(0,1) #=> ["a", "b"]
a.at(0,0) #=> ["a", "a")
a.at([2,3]) #=> ["c", "d"]
a.at([-1,1]) #=> ["e", "b"]
Updated by jeremyevans0 (Jeremy Evans) over 7 years ago
Array#values_at
already exists for this purpose:
a.values_at(0,1) #=> ["a", "b"]
a.values_at(0,0) #=> ["a", "a")
a.values_at(*[2,3]) #=> ["c", "d"]
a.values_at(*[-1,1]) #=> ["e", "b"]
Updated by crb002 (Chad Brewbaker) over 7 years ago
Well, I am an idiot. Read through the array spec twice and missed it both times. Please close.
Updated by shyouhei (Shyouhei Urabe) over 7 years ago
- Status changed from Open to Closed
No problem. Thank you anyway.
Actions
Like0
Like0Like0Like0