From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 3B52619C0032 for ; Wed, 4 Nov 2015 14:33:42 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id DCA20B5D834 for ; Wed, 4 Nov 2015 15:02:29 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id DE076952439 for ; Wed, 4 Nov 2015 15:02:29 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D17781204AB; Wed, 4 Nov 2015 15:02:28 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 0CF7F120485 for ; Wed, 4 Nov 2015 15:02:24 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=L1taA9ieXsEjxFIDcG3NDTnyivA=; b=y51HfaVOWoHbBXBXQr bCExwzNBHN6C3bYZdLUur20D3lPiEqFyKxXomlNo/2nAaJo/M8q/N2ULujHiNYj+ uUZ3FtOEtJeWfLrY+59sMLfhGeiD9r2YK1NK3Ycl9pUqcJoB9/PK/rQ13rmZycbR z08DB3k+RfaWy9tUqF2U0MNvs= Received: by filter0663p1mdw1.sendgrid.net with SMTP id filter0663p1mdw1.2922.56399F514 2015-11-04 06:01:53.027011008 +0000 UTC Received: from herokuapp.com (ec2-54-161-195-124.compute-1.amazonaws.com [54.161.195.124]) by ismtpd0001p1iad1.sendgrid.net (SG) with ESMTP id nm7L3HMmQhG5fXC18FlYSA for ; Wed, 04 Nov 2015 06:01:52.829 +0000 (UTC) Date: Wed, 04 Nov 2015 06:01:52 +0000 From: nobu@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 45970 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11653 X-Redmine-Issue-Author: danielpclark X-Redmine-Issue-Assignee: matz X-Redmine-Sender: nobu 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5a+9kCbP9F+toAthwJR6JPxnwjod2ErnU7dn 27dIb2l2MxFVumX+LP0gNwK+ldetSZr1OTDghrRGv9f0MQaDXCNzFw6cHwH7hbUSHw9qtF7i/j6YgL Dwq3PLtl2j8j1qc= X-ML-Name: ruby-core X-Mail-Count: 71330 Subject: [ruby-core:71330] [Ruby trunk - Feature #11653] Add to_proc on Hash 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11653 has been updated by Nobuyoshi Nakada. Description updated You can write it as: ~~~ruby [:e, :a, :b, :f, :c, :d].map(&my_hash.method(:[])) ~~~ ---------------------------------------- Feature #11653: Add to_proc on Hash https://bugs.ruby-lang.org/issues/11653#change-54704 * 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. ~~~ruby 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/