Skip to content

Commit a8f220e

Browse files
[DOC] Tweaks for Array#uniq (#11949)
1 parent 90ef28f commit a8f220e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

array.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6212,25 +6212,28 @@ rb_ary_uniq_bang(VALUE ary)
62126212

62136213
/*
62146214
* call-seq:
6215-
* array.uniq -> new_array
6216-
* array.uniq {|element| ... } -> new_array
6215+
* uniq -> new_array
6216+
* uniq {|element| ... } -> new_array
62176217
*
6218-
* Returns a new +Array+ containing those elements from +self+ that are not duplicates,
6218+
* Returns a new array containing those elements from +self+ that are not duplicates,
62196219
* the first occurrence always being retained.
62206220
*
6221-
* With no block given, identifies and omits duplicates using method <tt>eql?</tt>
6222-
* to compare:
6221+
* With no block given, identifies and omits duplicate elements using method <tt>eql?</tt>
6222+
* to compare elements:
62236223
*
62246224
* a = [0, 0, 1, 1, 2, 2]
62256225
* a.uniq # => [0, 1, 2]
62266226
*
62276227
* With a block given, calls the block for each element;
6228-
* identifies (using method <tt>eql?</tt>) and omits duplicate values,
6229-
* that is, those elements for which the block returns the same value:
6228+
* identifies and omits "duplicate" elements using method <tt>eql?</tt>
6229+
* to compare <i>block return values</i>;
6230+
* that is, an element is a duplicate if its block return value
6231+
* is the same as that of a previous element:
62306232
*
62316233
* a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb']
62326234
* a.uniq {|element| element.size } # => ["a", "aa", "aaa"]
62336235
*
6236+
* Related: {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
62346237
*/
62356238

62366239
static VALUE

0 commit comments

Comments
 (0)