From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.6 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 7806D1F4B5 for ; Tue, 12 Nov 2019 18:58:27 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id B5D201209DC; Wed, 13 Nov 2019 03:58:13 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 22707120969 for ; Wed, 13 Nov 2019 03:58:10 +0900 (JST) Received: by filter0078p3mdw1.sendgrid.net with SMTP id filter0078p3mdw1-18598-5DCB00C1-3E 2019-11-12 18:58:09.55687352 +0000 UTC m=+85873.402210221 Received: from herokuapp.com (unknown [54.162.83.60]) by ismtpd0078p1iad2.sendgrid.net (SG) with ESMTP id -2vVu8C7Rw6VLgHDS9FAAg for ; Tue, 12 Nov 2019 18:58:09.430 +0000 (UTC) Date: Tue, 12 Nov 2019 18:58:09 +0000 (UTC) From: non.dmitriy@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 71448 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16341 X-Redmine-Issue-Author: Nondv X-Redmine-Sender: Nondv 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: =?us-ascii?Q?EtUBU5pNPGGF695WqpG6VxCA85Kr9QQx+VRnpZEtiFfGXqt1XH+7PuVhS=2FsysY?= =?us-ascii?Q?R5=2F9ubVXe36zled0uBqBF37p2obHzXWDe8AxFZx?= =?us-ascii?Q?OD4DeAfWgCWsNs0fxYFYwqfIAa9h1BvWV4SiETI?= =?us-ascii?Q?vpvDSe43=2F+d5FQlRsRfbnrbiVOPar9SF7DUth6i?= =?us-ascii?Q?=2FoS2lW0M+JTOfgn=2F1VpIxRtrqIqLY92vVnQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95819 Subject: [ruby-core:95819] [Ruby master Feature#16341] Proposal: Set#to_proc 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 #16341 has been updated by Nondv (Dmitry Non). This *is* a syntactic sugar. Using `&` + `to_proc` in this case is the same (not technically, but algorithmically, I guess) as providing an explicit block `something.some_method { |x| some_set.include?(x) }` I don't find it crucial in any way and, to be honest, I don't really use sets that much (I prefer using hashes directly). But this feature could make some more a tiny bit easier to read from English language perspective (I *think*) ---------------------------------------- Feature #16341: Proposal: Set#to_proc https://bugs.ruby-lang.org/issues/16341#change-82646 * Author: Nondv (Dmitry Non) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- ``` ruby class Set def to_proc -> (x) { include?(x) } # or method(:include?).to_proc end end ``` Usage: ```ruby require 'set' banned_numbers = Set[0, 5, 7, 9] (1..10).reject(&banned_numbers) # ===> [1, 2, 3, 4, 6, 8, 10] ``` -- https://bugs.ruby-lang.org/