[#88925] [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical — ko1@...
Issue #15095 has been updated by ko1 (Koichi Sasada).
4 messages
2018/09/09
[#88927] Re: [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical
— Eric Wong <normalperson@...>
2018/09/09
[email protected] wrote:
[#88926] [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical — ko1@...
Issue #15095 has been updated by ko1 (Koichi Sasada).
3 messages
2018/09/09
[#89218] [Ruby trunk Bug#15130] open-uri hangs on cygwin — duerst@...
SXNzdWUgIzE1MTMwIGhhcyBiZWVuIHVwZGF0ZWQgYnkgZHVlcnN0IChNYXJ0aW4gRMO8cnN0KS4K
5 messages
2018/09/30
[ruby-core:88970] [Ruby trunk Feature#15111] Make the number of arguments of `Hash#merge` variable
From:
liukoki@...
Date:
2018-09-13 05:57:06 UTC
List:
ruby-core #88970
Issue #15111 has been reported by liwii (Koki Ryu).
----------------------------------------
Feature #15111: Make the number of arguments of `Hash#merge` variable
https://bugs.ruby-lang.org/issues/15111
* Author: liwii (Koki Ryu)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
# Abstract
Make the number of arguments of `Hash#merge` variable.
# Background
In many websites such as Stack Overflow and Qiita, many people are seeking how to merge more than three hashes.
https://stackoverflow.com/questions/19548496/how-to-merge-multiple-hashes-in-ruby
https://qiita.com/hc0208/items/c662f5189fa383872f4e
https://stackoverrun.com/ja/q/4997431
Many ways, like using `Enumerable#inject` or calling `Hash#merge` multiple times, are proposed, but both don't seem intuitive. Especially when using block in `Hash#merge`, the code becomes too complicated.
# Proposal
Change the argument of `Hash#merge` from singular to variable length.
# Implementation
https://github.com/ruby/ruby/pull/1951
# Evaluation
The code to merge more than three hashes became much simpler and more intuitive.
before
```ruby
hash1.merge(hash2).merge(hash3)
[hash1, hash2, hash3].inject do |result, part|
result.merge(part) { |key, value1, value2| key + value1 + value2 }
end
```
after
```ruby
hash1.merge(hash2, hash3)
hash1.merge(hash2, hash3) { |key, value1, value2| key + value1 + value2 }
```
# Discussion
# Summary
The change is needed to make `Hash#merge` more useful and intuitive.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>