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.1 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,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 ADA621F461 for ; Mon, 20 May 2019 07:23:15 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 41C7E12110B; Mon, 20 May 2019 16:23:09 +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 3E929120A1D for ; Mon, 20 May 2019 16:23:05 +0900 (JST) Received: by filter0071p3mdw1.sendgrid.net with SMTP id filter0071p3mdw1-11512-5CE255DA-E 2019-05-20 07:23:06.175556664 +0000 UTC m=+377063.993561476 Received: from herokuapp.com (unknown [3.84.188.62]) by ismtpd0042p1mdw1.sendgrid.net (SG) with ESMTP id Q_A3HbxuSdWPw3dDzjzibQ for ; Mon, 20 May 2019 07:23:06.105 +0000 (UTC) Date: Mon, 20 May 2019 07:23:06 +0000 (UTC) From: shyouhei@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68213 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15123 X-Redmine-Issue-Author: printercu X-Redmine-Issue-Assignee: matz X-Redmine-Sender: shyouhei 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?jcfQDMoo=2FMGCmP3uu1SeyLQUxUPXq5PjHpHz3xSFn15QARX6WfcHXXx7HX7m5f?= =?us-ascii?Q?1DxLhN7XgWDwl5PAb02fpUU9+h9tdDdFlze4CR5?= =?us-ascii?Q?Da13fxbtCQ8PHtxzIcgJXCq98S7+sz3o9NVL0PY?= =?us-ascii?Q?S2Y5sYkkx15yJIuBKaYhfNp5hRd5yADsd74H3KF?= =?us-ascii?Q?P6WgHkCV=2F=2F=2FRVGcyj88w0kpIRwjpzTkK+tA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92729 Subject: [ruby-core:92729] [Ruby trunk Feature#15123] Enumerable#compact proposal 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 #15123 has been updated by shyouhei (Shyouhei Urabe). Just leaving a comment that I wanted this method in my pet project just now. So +1. ---------------------------------------- Feature #15123: Enumerable#compact proposal https://bugs.ruby-lang.org/issues/15123#change-78088 * Author: printercu (Max Melentiev) * Status: Open * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- Hi! While Enumerable does not provide `#compact` method, it requires changing code in some cases to substitute array with enumerator. For example, to reduce memory usage it's usual to change `large_array.map { to_heavy_object }.chained_methods` to `large_array.lazy...`. However if `chained_methods` contains `compact`, this change will fail. Replacing `compact` with `reject(&:nil?)` fixes it. What do you think about adding `#compact` to Enumerable? -- https://bugs.ruby-lang.org/