ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: duerst@it.aoyama.ac.jp
To: ruby-core@ruby-lang.org
Subject: [ruby-core:71329] [Ruby trunk - Feature #11653] Add to_proc on Hash
Date: Wed, 04 Nov 2015 05:24:44 +0000	[thread overview]
Message-ID: <redmine.journal-54703.20151104052444.0e77227b8f9fb5ea@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11653.20151104025915@ruby-lang.org

Issue #11653 has been updated by Martin Dürst.

Assignee set to Yukihiro Matsumoto

I think this is an excellent idea. I hope this can make it into Ruby 2.3.

----------------------------------------
Feature #11653: Add to_proc on Hash
https://bugs.ruby-lang.org/issues/11653#change-54703

* Author: Daniel P. Clark
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
Procs can be called the same way a hash is with `[]`.  But a Hash is not mappable as a Proc.

    my_hash = ->key{{
      a: 1, b: 2, c: 3, d: 4, e: 5, f: 6
    }[key]}

    my_hash[:a]
    # => 1

    [:e, :a, :b, :f, :c, :d].map(&my_hash) # hash is now mappable
    # => [5, 1, 2, 6, 3, 4]

This seems so straight forward I believe it should be part of the language itself with the .to_proc method call.



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2015-11-04  4:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11653.20151104025915@ruby-lang.org>
2015-11-04  2:59 ` [ruby-core:71327] [Ruby trunk - Feature #11653] [Open] Add to_proc on Hash 6ftdan
2015-11-04  5:24 ` duerst [this message]
2015-11-04  6:01 ` [ruby-core:71330] [Ruby trunk - Feature #11653] " nobu
2015-11-09  8:03 ` [ruby-core:71404] " matz
2015-11-09 14:32   ` [ruby-core:71416] Unsubscribe Dan Whiteside
2015-11-09  8:08 ` [ruby-core:71405] [Ruby trunk - Feature #11653] Add to_proc on Hash ko1
2016-06-24  8:34 ` [ruby-core:76135] [Ruby trunk Feature#11653] " Ruby-Lang
2016-06-25  5:01 ` [ruby-core:76140] " duerst

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-54703.20151104052444.0e77227b8f9fb5ea@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).