ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: grzegorz.jakubiak@outlook.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:92505] [Ruby trunk Feature#15323] [PATCH] Proposal: Add Enumerable#filter_map
Date: Tue, 30 Apr 2019 21:35:59 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-77866.20190430213559.dde17717bba5eada@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15323.20181120115943@ruby-lang.org

Issue #15323 has been updated by greggzst (Grzegorz Jakubiak).


alfonsojimenez (Alfonso Jiménez) wrote:
> I've updated the patch file increasing the ruby version in *spec/ruby/core/enumerable/filter_map_spec.rb*
> 
> `Enumerable#filter_map` was already accepted in the last developers meeting: https://docs.google.com/document/u/2/d/e/2PACX-1vTUCmj7aUdnMAdunG0AZo0AdWK-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énez)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
This is a proposal for a combined `filter` + `map` method (https://bugs.ruby-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? } #=> [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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

  parent reply	other threads:[~2019-04-30 21:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15323.20181120115943@ruby-lang.org>
2018-11-20 11:59 ` [ruby-core:89907] [Ruby trunk Feature#15323] [PATCH] Proposal: Add Enumerable#filter_map me
2018-11-20 14:29 ` [ruby-core:89908] " tonysunnymails
2018-11-20 17:07 ` [ruby-core:89912] " shevegen
2018-12-14 19:58 ` [ruby-core:90531] " nardonykolyszyn
2018-12-14 20:22   ` [ruby-core:90532] " oleynikov
2018-12-17  3:43 ` [ruby-core:90582] " matthew
2019-02-13  2:41 ` [ruby-core:91524] " shugo
2019-04-25  9:54 ` [ruby-core:92406] " me
2019-04-30 21:35 ` grzegorz.jakubiak [this message]
2019-05-22  6:06 ` [ruby-core:92764] " matz
2019-05-23 15:46 ` [ruby-core:92802] " nobu
2019-10-06 19:16 ` [ruby-core:95248] [Ruby master " jonathan
2019-10-06 19:22 ` [ruby-core:95249] " eregontp
2019-10-06 20:43 ` [ruby-core:95251] " jonathan
2019-10-08 21:35 ` [ruby-core:95283] " eregontp
2019-10-11  2:34 ` [ruby-core:95300] " joshua.goodall
2019-11-04 21:32 ` [ruby-core:95679] " shevegen
2019-11-04 21:35 ` [ruby-core:95681] " shevegen
2019-11-28  4:19 ` [ruby-core:96005] " nobu

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.journal-77866.20190430213559.dde17717bba5eada@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).