From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id C9FC71F453 for ; Fri, 5 Oct 2018 14:02:06 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8C10C120C2B; Fri, 5 Oct 2018 23:02:03 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id EDFDB120C2B for ; Fri, 5 Oct 2018 23:02:00 +0900 (JST) Received: by filter0079p3mdw1.sendgrid.net with SMTP id filter0079p3mdw1-22566-5BB76EC3-3 2018-10-05 14:01:39.055523008 +0000 UTC m=+135684.278125838 Received: from herokuapp.com (ec2-23-20-187-140.compute-1.amazonaws.com [23.20.187.140]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id j2qvQwzvQB--_6YCtS01PA for ; Fri, 05 Oct 2018 14:01:39.001 +0000 (UTC) Date: Fri, 05 Oct 2018 14:01:53 +0000 (UTC) From: c4am95@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 64680 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15198 X-Redmine-Issue-Author: c4am95 X-Redmine-Sender: c4am95 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7DZOODRsat24mUeUl8Uapj7DDvueq4Be60P2 K/z25kqmg/5nWYS32U9dpKpQ3nN7fvKR21SlQiw4esAr1aEFvIxaYJBgyxUUQHfuc0atcQb/rhYou7 l9oYLPh+EMzthKm6g9mp+znfekIZZTPN49lV X-ML-Name: ruby-core X-Mail-Count: 89287 Subject: [ruby-core:89287] [Ruby trunk Feature#15198] Array#intersect? X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" 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/