[#76442] [Ruby trunk Feature#11741] Migrate Ruby to Git from Subversion — naruse@...
Issue #11741 has been updated by Yui NARUSE.
3 messages
2016/07/19
[#76515] [Ruby trunk Bug#12610] webrick: protect from httpoxy — nagachika00@...
Issue #12610 has been updated by Tomoyuki Chikanaga.
3 messages
2016/07/22
[ruby-core:76460] [Ruby trunk Feature#10208] Passing block to Enumerable#to_h
From:
shyouhei@...
Date:
2016-07-20 02:20:19 UTC
List:
ruby-core #76460
Issue #10208 has been updated by Shyouhei Urabe.
We looked at this issue at yesterday's developer meeting and had consensus that there is no other example of to_* method that takes a block. Introducing such new concept seems too risky.
----------------------------------------
Feature #10208: Passing block to Enumerable#to_h
https://bugs.ruby-lang.org/issues/10208#change-59705
* Author: Yutaka HARA
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
Now that we can convert 'a list of [key, value] pairs' into a hash with Enumerable#to_h,
how about make it take a block to specify 'how to convert each element into a [key, value] pair'?
Example:
~~~
# Convert users into an {id => name} hash
users.map{|u| [u.id, u.name]}.to_h
↓
# Convert users into an {id => name} hash
users.to_h{|u| [u.id, u.name]}
~~~
This could also be a solution for these feature requests:
* Feature #6669 A method like Hash#map but returns hash
hsh.apply{|k, v| [k.to_s, v]}
== hsh.to_h{|k, v| [k.to_s, v]}
* Feature #7793 New methods on Hash
Feature #9970 Add `Hash#map_keys` and `Hash#map_values`
hsh.map_k(&:to_s)
== hsh.to_h{|k, v| [k.to_s, v]}
hsh.map_v(&:to_i)
== hsh.to_h{|k, v| [k, v.to_i]}
hsh.map_kv(&block)
== hsh.to_h(&block)
--
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>