[DOC] Tweaks for Array#pop (#11821)
This commit is contained in:
parent
45edfa73ce
commit
a320833013
Notes:
git
2024-10-08 15:11:09 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>
29
array.c
29
array.c
@ -1448,33 +1448,32 @@ rb_ary_pop(VALUE ary)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* array.pop -> object or nil
|
* pop -> object or nil
|
||||||
* array.pop(n) -> new_array
|
* pop(count) -> new_array
|
||||||
*
|
*
|
||||||
* Removes and returns trailing elements.
|
* Removes and returns trailing elements of +self+.
|
||||||
*
|
*
|
||||||
* When no argument is given and +self+ is not empty,
|
* With no argument given, removes and returns the last element, if available;
|
||||||
* removes and returns the last element:
|
* otherwise returns +nil+:
|
||||||
*
|
*
|
||||||
* a = [:foo, 'bar', 2]
|
* a = [:foo, 'bar', 2]
|
||||||
* a.pop # => 2
|
* a.pop # => 2
|
||||||
* a # => [:foo, "bar"]
|
* a # => [:foo, "bar"]
|
||||||
|
* [].pop # => nil
|
||||||
*
|
*
|
||||||
* Returns +nil+ if the array is empty.
|
* With non-negative integer argument +count+ given,
|
||||||
|
* returns a new array containing the trailing +count+ elements of +self+, as available:
|
||||||
*
|
*
|
||||||
* When a non-negative Integer argument +n+ is given and is in range,
|
|
||||||
*
|
|
||||||
* removes and returns the last +n+ elements in a new +Array+:
|
|
||||||
* a = [:foo, 'bar', 2]
|
* a = [:foo, 'bar', 2]
|
||||||
* a.pop(2) # => ["bar", 2]
|
* a.pop(2) # => ["bar", 2]
|
||||||
*
|
* a # => [:foo]
|
||||||
* If +n+ is positive and out of range,
|
|
||||||
* removes and returns all elements:
|
|
||||||
*
|
*
|
||||||
* a = [:foo, 'bar', 2]
|
* a = [:foo, 'bar', 2]
|
||||||
* a.pop(50) # => [:foo, "bar", 2]
|
* a.pop(50) # => [:foo, "bar", 2]
|
||||||
|
* a # => []
|
||||||
*
|
*
|
||||||
* Related: #push, #shift, #unshift.
|
* Related: Array#push;
|
||||||
|
* see also {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user