summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2023-05-09 02:22:52 -0700
committerJeremy Evans <code@jeremyevans.net>2023-05-09 02:25:56 -0700
commit986268afae7bde07073da3ba483d12549b12801f (patch)
tree00cc19d6ab049b68769b490d9cb9de487114ce05
parent091d04ccce90329e8df2882c705ffd92aea96603 (diff)
downloadruby-986268afae7bde07073da3ba483d12549b12801f.tar.gz
Document that Array#{&,intersection,intersect?} use hash method [ci skip]
Fixes [Bug #19622]
-rw-r--r--array.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/array.c b/array.c
index 1eb1f1ced9..622e17905d 100644
--- a/array.c
+++ b/array.c
@@ -5647,7 +5647,8 @@ rb_ary_difference_multi(int argc, VALUE *argv, VALUE ary)
* array & other_array -> new_array
*
* Returns a new \Array containing each element found in both +array+ and \Array +other_array+;
- * duplicates are omitted; items are compared using <tt>eql?</tt>:
+ * duplicates are omitted; items are compared using <tt>eql?</tt>
+ * (items must also implement +hash+ correctly):
*
* [0, 1, 2, 3] & [1, 2] # => [1, 2]
* [0, 1, 0, 1] & [0, 1] # => [0, 1]
@@ -5700,7 +5701,8 @@ rb_ary_and(VALUE ary1, VALUE ary2)
*
* Returns a new \Array containing each element found both in +self+
* and in all of the given Arrays +other_arrays+;
- * duplicates are omitted; items are compared using <tt>eql?</tt>:
+ * duplicates are omitted; items are compared using <tt>eql?</tt>
+ * (items must also implement +hash+ correctly):
*
* [0, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
* [0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
@@ -5849,6 +5851,8 @@ rb_ary_union_multi(int argc, VALUE *argv, VALUE ary)
* a.intersect?(b) #=> true
* a.intersect?(c) #=> false
*
+ * Array elements are compared using <tt>eql?</tt>
+ * (items must also implement +hash+ correctly).
*/
static VALUE