[DOC] Tweaks for Array#difference (#11593)

This commit is contained in:
Burdette Lamar 2024-09-11 12:14:41 -05:00 committed by GitHub
parent c7faffd1d6
commit 18fb11aaa4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-09-11 17:14:59 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>

12
array.c
View File

@ -5521,19 +5521,21 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
/* /*
* call-seq: * call-seq:
* array.difference(*other_arrays) -> new_array * difference(*other_arrays = []) -> new_array
* *
* Returns a new +Array+ containing only those elements from +self+ * Returns a new array containing only those elements from +self+
* that are not found in any of the Arrays +other_arrays+; * that are not found in any of the given +other_arrays+;
* items are compared using <tt>eql?</tt>; order from +self+ is preserved: * items are compared using <tt>eql?</tt>; order from +self+ is preserved:
* *
* [0, 1, 1, 2, 1, 1, 3, 1, 1].difference([1]) # => [0, 2, 3] * [0, 1, 1, 2, 1, 1, 3, 1, 1].difference([1]) # => [0, 2, 3]
* [0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2] * [0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2]
* [0, 1, 2].difference([4]) # => [0, 1, 2] * [0, 1, 2].difference([4]) # => [0, 1, 2]
* [0, 1, 2].difference # => [0, 1, 2]
* *
* Returns a copy of +self+ if no arguments given. * Returns a copy of +self+ if no arguments are given.
* *
* Related: Array#-. * Related: Array#-;
* see also {Methods for Combining}[rdoc-ref:Array@Methods+for+Combining].
*/ */
static VALUE static VALUE