Issue #15198 has been updated by knu (Akinori MUSHA).


We discussed this in today's developer meeting.  Here are some remarks:

- It takes one argument for now.
- It means !(a & b).empty? instead of (a & b).any? so [nil].intersect?([nil]) evaluates to true.
- The implementation will internally use a hash to match the behavior of Array#&.


----------------------------------------
Feature #15198: Array#intersect?
https://bugs.ruby-lang.org/issues/15198#change-91573

* Author: c4am95 (Travis Hunter)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
I frequently find myself needing to determine if two arrays intersect but not actually caring about the intersection, so I write code like:
~~~ ruby
(a1 & a2).any?
~~~

It would be nice to have an **intersect?** convenience method on **Array** to perform this query.

[ruby#1972: Add Array#intersect?](https://github.com/ruby/ruby/pull/1972)



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>