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

From: c4am95@...
Date: 2018-10-05 14:01:53 UTC
List: ruby-core #89287
Issue #15198 has been updated by c4am95 (Travis Hunter).


The most recent example I encountered was authorizing a user in a Rails endpoint. Each user has a list of abilities, and each endpoint has a list of abilities that is authorized to perform the action. We just need to check if there is an intersection between the two lists.

I updated the PR to avoid creating the intermediate array.

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

* 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:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next