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.4 required=3.0 tests=AWL,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 3EBD51F404 for ; Sat, 15 Sep 2018 11:06:27 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 2B724120969; Sat, 15 Sep 2018 20:06:24 +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 62956120962 for ; Sat, 15 Sep 2018 20:06:21 +0900 (JST) Received: by filter0137p3mdw1.sendgrid.net with SMTP id filter0137p3mdw1-27475-5B9CE7A8-F 2018-09-15 11:06:16.705909492 +0000 UTC m=+57541.432891717 Received: from herokuapp.com (ec2-54-166-193-109.compute-1.amazonaws.com [54.166.193.109]) by ismtpd0010p1iad1.sendgrid.net (SG) with ESMTP id 2a7F_-SsQZSmNSHaigX1NQ Sat, 15 Sep 2018 11:06:16.687 +0000 (UTC) Date: Sat, 15 Sep 2018 11:06:17 +0000 (UTC) From: shevegen@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 64422 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15123 X-Redmine-Issue-Author: printercu X-Redmine-Issue-Assignee: matz 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: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6lG9scG8m+R9d3mLh80m42RHQi+3prWExzMs 66IsmEobA0OCHz0kdsKoyHlScad08eA50masPZ39Zb1dGceCiPD96qnc62xR1VfdnaOSPepgFj6gLw NCDj6GLqirxvFJr/3QO6Yf78Z5ilnmkqjkgKqo6MpBK7Dxar0Co+RLF3BQ== X-ML-Name: ruby-core X-Mail-Count: 89029 Subject: [ruby-core:89029] [Ruby trunk Bug#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 shevegen (Robert A. Heiler). I think if the meaning is consistent (e. g. .compact meaning to eliminate nil values from a given collection) then this seems ok. Perhaps this could be added for the next developer meeting. ---------------------------------------- Bug #15123: Enumerable#compact proposal https://bugs.ruby-lang.org/issues/15123#change-74053 * Author: printercu (Max Melentiev) * Status: Open * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: * ruby -v: * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- 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/