Skip to content

Commit

Permalink
[DOC] Tweaks for Array#uniq (ruby#11949)
Browse files Browse the repository at this point in the history
  • Loading branch information
BurdetteLamar authored Oct 28, 2024
1 parent 90ef28f commit a8f220e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a8f220e

Please sign in to comment.