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=-4.0 required=3.0 tests=BAYES_00, 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.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 56C6F1F453 for ; Tue, 30 Apr 2019 21:36:07 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 63005120A43; Wed, 1 May 2019 06:36:01 +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 D4C4A120906 for ; Wed, 1 May 2019 06:35:58 +0900 (JST) Received: by filter0062p3mdw1.sendgrid.net with SMTP id filter0062p3mdw1-29555-5CC8BFBF-2F 2019-04-30 21:35:59.541230572 +0000 UTC m=+436888.159105616 Received: from herokuapp.com (unknown [3.86.82.84]) by ismtpd0035p1mdw1.sendgrid.net (SG) with ESMTP id FV2CSLaJSTGigfwOKoy9rQ for ; Tue, 30 Apr 2019 21:35:59.741 +0000 (UTC) Date: Tue, 30 Apr 2019 21:35:59 +0000 (UTC) From: grzegorz.jakubiak@outlook.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67988 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15323 X-Redmine-Issue-Author: alfonsojimenez X-Redmine-Sender: greggzst 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?VGo1Yotd4zCzfg3lZZGknPzkEWcl6BbwQWWlBuZDX4Y7dCWTFW5Sa13VeKSq+h?= =?us-ascii?Q?C9q=2FZfAD46+icCypYN4OtZd9+w=2FNddElzWstsbz?= =?us-ascii?Q?+0kPreJInxaV4lNLeJ8EFl0gwZKtMrv4h3NAgzn?= =?us-ascii?Q?OiSf8WCV1o41u6JP+BZa4fYXraid2eVmTUvY+aI?= =?us-ascii?Q?bqV7djPLaBDH8A4eqxUh5iE5EFQxU8YG=2FzA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92505 Subject: [ruby-core:92505] [Ruby trunk Feature#15323] [PATCH] Proposal: Add Enumerable#filter_map 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="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15323 has been updated by greggzst (Grzegorz Jakubiak). alfonsojimenez (Alfonso Jim=E9nez) wrote: > I've updated the patch file increasing the ruby version in *spec/ruby/cor= e/enumerable/filter_map_spec.rb* > = > `Enumerable#filter_map` was already accepted in the last developers meeti= ng: https://docs.google.com/document/u/2/d/e/2PACX-1vTUCmj7aUdnMAdunG0AZo0A= dWK-9jvfXcB7DWYmzGtmPc0IuIPGn7eLARoR5tBd6XUUB08W-hH74k-T/pub Does the syntax allow for this kind of code? ~~~ruby (1..10).filter_map(&:even?) { |i| i * 2 } ~~~ ---------------------------------------- Feature #15323: [PATCH] Proposal: Add Enumerable#filter_map https://bugs.ruby-lang.org/issues/15323#change-77866 * Author: alfonsojimenez (Alfonso Jim=E9nez) * Status: Open * Priority: Normal * Assignee: = * Target version: = ---------------------------------------- This is a proposal for a combined `filter` + `map` method (https://bugs.rub= y-lang.org/issues/5663). This method both filters and maps the elements of an enumerable in just one= iteration: ~~~ ruby (1..10).filter_map { |i| i * 2 if i.even? } #=3D> [4, 8, 12, 16, 20] ~~~ GitHub PR: https://github.com/ruby/ruby/pull/2017 = ---Files-------------------------------- 0001-Adding-Enumerable-filter_map.patch (4.61 KB) -- = https://bugs.ruby-lang.org/ Unsubscribe: