summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorBurdette Lamar <[email protected]>2024-10-11 10:30:52 -0500
committer<[email protected]>2024-10-11 11:30:52 -0400
commit77c7d88015aa7454f2c34d54ec313dc4dc464ae0 ()
tree9541a143b8936929352848aa9c8e2bfc0b56964b /array.c
parent628da153bb184285aee864b4548f974e547d839d (diff)
[DOC] Tweaks for Array#rotate! (#11875)
Notes: Merged-By: peterzhu2118 <[email protected]>
-rw-r--r--array.c36
1 files changed, 11 insertions, 25 deletions
@@ -3186,48 +3186,34 @@ rb_ary_rotate(VALUE ary, long cnt)
/*
* call-seq:
- * array.rotate! -> self
- * array.rotate!(count) -> self
*
* Rotates +self+ in place by moving elements from one end to the other; returns +self+.
*
- * When no argument given, rotates the first element to the last position:
- *
- * a = [:foo, 'bar', 2, 'bar']
- * a.rotate! # => ["bar", 2, "bar", :foo]
- *
- * When given a non-negative Integer +count+,
* rotates +count+ elements from the beginning to the end:
*
- * a = [:foo, 'bar', 2]
- * a.rotate!(2)
- * a # => [2, :foo, "bar"]
*
* If +count+ is large, uses <tt>count % array.size</tt> as the count:
*
- * a = [:foo, 'bar', 2]
- * a.rotate!(20)
- * a # => [2, :foo, "bar"]
*
- * If +count+ is zero, returns +self+ unmodified:
*
- * a = [:foo, 'bar', 2]
- * a.rotate!(0)
- * a # => [:foo, "bar", 2]
*
- * When given a negative Integer +count+, rotates in the opposite direction,
* from end to beginning:
*
- * a = [:foo, 'bar', 2]
- * a.rotate!(-2)
- * a # => ["bar", 2, :foo]
*
* If +count+ is small (far from zero), uses <tt>count % array.size</tt> as the count:
*
- * a = [:foo, 'bar', 2]
- * a.rotate!(-5)
- * a # => ["bar", 2, :foo]
*
*/
static VALUE