ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: melentievm@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:89017] [Ruby trunk Bug#15123] Enumerable#compact proposal
Date: Fri, 14 Sep 2018 17:30:06 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-15123.20180914173004.e559258cfc6cbc93@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15123.20180914173004@ruby-lang.org

Issue #15123 has been reported by printercu (Max Melentiev).

----------------------------------------
Bug #15123: Enumerable#compact proposal
https://bugs.ruby-lang.org/issues/15123

* Author: printercu (Max Melentiev)
* Status: Open
* Priority: Normal
* Assignee: 
* 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/

       reply	other threads:[~2018-09-14 17:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15123.20180914173004@ruby-lang.org>
2018-09-14 17:30 ` melentievm [this message]
2018-09-14 19:43 ` [ruby-core:89019] [Ruby trunk Bug#15123] Enumerable#compact proposal grzegorz.jakubiak
2018-09-15  2:37 ` [ruby-core:89023] " ruby-core
2018-09-15  7:46 ` [ruby-core:89026] " eregontp
2018-09-15 11:06 ` [ruby-core:89029] " shevegen
2018-09-15 14:38 ` [ruby-core:89031] " ruby-core
2019-05-20  7:23 ` [ruby-core:92729] [Ruby trunk Feature#15123] " shyouhei
2019-09-02  5:28 ` [ruby-core:94721] [Ruby master " matz
2019-10-30 19:30 ` [ruby-core:95592] " keystonelemur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.issue-15123.20180914173004.e559258cfc6cbc93@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).