From: c4am95@... Date: 2018-10-07T23:19:52+00:00 Subject: [ruby-core:89309] [Ruby trunk Feature#15198] Array#intersect? Issue #15198 has been updated by c4am95 (Travis Hunter). I threw together a contrived example in a [gist](https://gist.github.com/travisofthenorth/eb2a68f5cd309dc7442ec4e1e55ae117) which is very similar to the use case I described. I have also run into numerous other situations where this functionality would have been useful. I added some comments in the gist but I'll cross-post them here for reference: > The current behavior creates an intermediate array for both intersection tests when the resulting array is clearly not needed. With the desired behavior, we could avoid creating the intermediate array and produce a faster best case runtime. ---------------------------------------- Feature #15198: Array#intersect? https://bugs.ruby-lang.org/issues/15198#change-74338 * 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: