Project

General

Profile

Actions

Feature #13118

closed

Array#at(*indexes); Array#at([indexes])

Added by crb002 (Chad Brewbaker) over 7 years ago. Updated over 7 years ago.

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

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"]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0