Method: Array#rotate!
- Defined in:
- ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb
#rotate!(count = 1) ⇒ Object
call-seq:
ary.rotate!(count=1) -> ary
Rotates +self+ in place so that the element at +count+ comes first, and
returns +self+.
If +count+ is negative then it rotates in the opposite direction, starting
from the end of the array where +-1+ is the last element.
a = [ "a", "b", "c", "d" ]
a.rotate! #=> ["b", "c", "d", "a"]
a #=> ["b", "c", "d", "a"]
a.rotate!(2) #=> ["d", "a", "b", "c"]
a.rotate!(-3) #=> ["a", "b", "c", "d"]
492 493 494 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb', line 492 def rotate!(count=1) self.replace(self.rotate(count)) end |