[ruby-core:89273] [Ruby trunk Feature#15198] Array#intersect?

From: shyouhei@...
Date: 2018-10-04 02:28:22 UTC
List: ruby-core #89273
Issue #15198 has been updated by shyouhei (Shyouhei Urabe).


- Interesting.  Can you share a bit more detail about your "if two arrays intersect but not actually caring about the intersection" use case?  For instance if you have open sourced such code, a URL for it helps us a lot.

- If you have zero interest to the intersection itself I think you can avoid creating the temporary array.

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

* Author: c4am95 (Travis Hunter)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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>

In This Thread

Prev Next