summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorBurdette Lamar <[email protected]>2024-10-25 09:52:22 -0500
committerGitHub <[email protected]>2024-10-25 10:52:22 -0400
commit05f894aba2b65663e5a092f0da136c6d8a3751c7 (patch)
tree0844a8f6af3a6eb6e3e56a22f2933c9e56d93cd9 /array.c
parent5c1e43277e12c2ca001945b302b5c12bf3093ed9 (diff)
[DOC] Tweaks for Array#uniq! (#11950)
Notes
Notes: Merged-By: peterzhu2118 <[email protected]>
Diffstat (limited to 'array.c')
-rw-r--r--array.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/array.c b/array.c
index 318b7763ec..755412cd96 100644
--- a/array.c
+++ b/array.c
@@ -6155,32 +6155,30 @@ push_value(st_data_t key, st_data_t val, st_data_t ary)
/*
* call-seq:
- * array.uniq! -> self or nil
- * array.uniq! {|element| ... } -> self or nil
+ * uniq! -> self or nil
+ * uniq! {|element| ... } -> self or nil
*
* Removes duplicate elements from +self+, the first occurrence always being retained;
* returns +self+ if any elements removed, +nil+ otherwise.
*
* With no block given, identifies and removes elements using method <tt>eql?</tt>
- * to compare.
- *
- * Returns +self+ if any elements removed:
+ * to compare elements:
*
* a = [0, 0, 1, 1, 2, 2]
* a.uniq! # => [0, 1, 2]
- *
- * Returns +nil+ if no elements removed.
+ * a.uniq! # => nil
*
* With a block given, calls the block for each element;
- * identifies (using method <tt>eql?</tt>) and removes
- * elements for which the block returns duplicate values.
- *
- * Returns +self+ if any elements removed:
+ * 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']
+ * a.uniq! {|element| element.size } # => ["a", "aa", "aaa"]
+ * a.uniq! {|element| element.size } # => nil
*
- * Returns +nil+ if no elements removed.
+ * Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/
static VALUE
rb_ary_uniq_bang(VALUE ary)