Skip to content

Commit b44a154

Browse files
BurdetteLamarpeterzhu2118
authored andcommitted
[DOC] Tweaks for Array#&
1 parent 0dda30d commit b44a154

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

array.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5501,20 +5501,30 @@ rb_ary_difference_multi(int argc, VALUE *argv, VALUE ary)
55015501

55025502
/*
55035503
* call-seq:
5504-
* array & other_array -> new_array
5504+
* self & other_array -> new_array
55055505
*
5506-
* Returns a new +Array+ containing each element found in both +array+ and +Array+ +other_array+;
5507-
* duplicates are omitted; items are compared using <tt>eql?</tt>
5508-
* (items must also implement +hash+ correctly):
5506+
* Returns a new +Array+ object containing the _intersection_ of +self+ and +other_array+;
5507+
* that is, containing those elements found in both +self+ and +other_array+:
55095508
*
55105509
* [0, 1, 2, 3] & [1, 2] # => [1, 2]
5511-
* [0, 1, 0, 1] & [0, 1] # => [0, 1]
55125510
*
5513-
* Preserves order from +array+:
5511+
* Omits duplicates:
5512+
*
5513+
* [0, 1, 1, 0] & [0, 1] # => [0, 1]
5514+
*
5515+
* Preserves order from +self+:
55145516
*
55155517
* [0, 1, 2] & [3, 2, 1, 0] # => [0, 1, 2]
55165518
*
5517-
* Related: Array#intersection.
5519+
* Identifies common elements using method <tt>#eql?</tt>
5520+
* (as defined in each element of +self+).
5521+
*
5522+
* Related:
5523+
*
5524+
* - Array#intersection: intersection of +self+ and multiple other arrays.
5525+
* - Array#|: union of +self+ and one other array.
5526+
* - Array#union: union of +self+ and multiple other arrays.
5527+
*
55185528
*/
55195529

55205530

0 commit comments

Comments
 (0)