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.7 required=3.0 tests=AWL,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 4AF941F454 for ; Mon, 4 Nov 2019 21:32:48 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 6C3131209C3; Tue, 5 Nov 2019 06:32:37 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id EC9D4120941 for ; Tue, 5 Nov 2019 06:32:34 +0900 (JST) Received: by filter0178p3mdw1.sendgrid.net with SMTP id filter0178p3mdw1-8809-5DC098F8-3F 2019-11-04 21:32:40.505380581 +0000 UTC m=+10094.466817346 Received: from herokuapp.com (unknown [3.88.230.70]) by ismtpd0036p1iad1.sendgrid.net (SG) with ESMTP id muf3PzSaSki2GQoBR8fBWg for ; Mon, 04 Nov 2019 21:32:40.469 +0000 (UTC) Date: Mon, 04 Nov 2019 21:32:40 +0000 (UTC) From: shevegen@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 71271 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15323 X-Redmine-Issue-Author: alfonsojimenez X-Redmine-Sender: shevegen 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?6lbdtOg4RDRLuxD00eQtQKgoNAsge5d4xND7cbMQd0xHbRtnnZuMz14ejU1cAp?= =?us-ascii?Q?w9npDUOxItqM01EOur8FJClAGI0=2F6hbb9lpbrBI?= =?us-ascii?Q?LcOx2OUKg9mnGw5SmB7kzH7LYMrLb4Hn3KzNoDI?= =?us-ascii?Q?ygKFBraG8Z8cZkuNK5K=2FAPg=2FTxu93AUin19pQi9?= =?us-ascii?Q?cgYYicRKPXsYhAwHKC=2Fo+jDn=2FhyVZUvXfwQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95679 Subject: [ruby-core:95679] [Ruby master 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 shevegen (Robert A. Heiler). Jonathan recently added this to the upcoming developer discussion (at https= ://bugs.ruby-lang.org/issues/16262), in regards as to whether the current behaviour is correct, or whether it sh= ould include non-nil values as well. The question is whether the behaviour should be like Array#compact or not. I can not say much about Array#compact, but from the name filter_map alone,= I would assume that first a filter is used (as a "positive" .select), and then the .map is applied. If this re= asoning makes any sense to anyone else, then I believe that the behaviour shown by .filter_map as-is is corre= ct and should be retained. But this is just my opinion - my reasoning comes primarily from the name itself= (.filter_map that is). ---------------------------------------- Feature #15323: [PATCH] Proposal: Add Enumerable#filter_map https://bugs.ruby-lang.org/issues/15323#change-82466 * Author: alfonsojimenez (Alfonso Jim=E9nez) * Status: Closed * 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: