[DOC] Tweaks for Array#collect! (#11434)

This commit is contained in:
Burdette Lamar 2024-08-22 19:59:59 -05:00 committed by GitHub
parent fdba458e85
commit 784ccd0115
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-08-23 01:00:19 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>

18
array.c
View File

@ -3700,21 +3700,19 @@ rb_ary_collect(VALUE ary)
/*
* call-seq:
* array.map! {|element| ... } -> self
* array.map! -> new_enumerator
* collect! {|element| ... } -> new_array
* collect! -> new_enumerator
* map! {|element| ... } -> new_array
* map! -> new_enumerator
*
* Calls the block, if given, with each element;
* replaces the element with the block's return value:
* With a block given, calls the block with each element of +self+
* and replaces the element with the block's return value;
* returns +self+:
*
* a = [:foo, 'bar', 2]
* a.map! { |element| element.class } # => [Symbol, String, Integer]
*
* Returns a new Enumerator if no block given:
*
* a = [:foo, 'bar', 2]
* a1 = a.map!
* a1 # => #<Enumerator: [:foo, "bar", 2]:map!>
*
* With no block given, returns a new Enumerator.
*/
static VALUE