[DOC] Tweaks for Array#uniq (#11949)

This commit is contained in:
Burdette Lamar 2024-10-28 09:05:49 -05:00 committed by GitHub
parent 90ef28f59b
commit a8f220ed90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-10-28 14:06:08 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>

17
array.c
View File

@ -6212,25 +6212,28 @@ rb_ary_uniq_bang(VALUE ary)
/*
* call-seq:
* array.uniq -> new_array
* array.uniq {|element| ... } -> new_array
* uniq -> new_array
* uniq {|element| ... } -> new_array
*
* Returns a new +Array+ containing those elements from +self+ that are not duplicates,
* Returns a new array containing those elements from +self+ that are not duplicates,
* the first occurrence always being retained.
*
* With no block given, identifies and omits duplicates using method <tt>eql?</tt>
* to compare:
* With no block given, identifies and omits duplicate elements using method <tt>eql?</tt>
* to compare elements:
*
* a = [0, 0, 1, 1, 2, 2]
* a.uniq # => [0, 1, 2]
*
* With a block given, calls the block for each element;
* identifies (using method <tt>eql?</tt>) and omits duplicate values,
* that is, those elements for which the block returns the same value:
* identifies and omits "duplicate" elements using method <tt>eql?</tt>
* to compare <i>block return values</i>;
* that is, an element is a duplicate if its block return value
* is the same as that of a previous element:
*
* a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb']
* a.uniq {|element| element.size } # => ["a", "aa", "aaa"]
*
* Related: {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE