method
rotate
v1_9_2_180 -
Show latest stable
- Class:
Array
rotate(p1 = v1)public
Returns new array by rotating self, whose first element is the element at cnt in self. If cnt is negative then it rotates in counter direction.
a = [ "a", "b", "c", "d" ] a.rotate #=> ["b", "c", "d", "a"] a #=> ["a", "b", "c", "d"] a.rotate(2) #=> ["c", "d", "a", "b"] a.rotate(-3) #=> ["b", "c", "d", "a"]