From: sawadatsuyoshi@... Date: 2015-12-02T06:48:47+00:00 Subject: [ruby-core:71795] [Ruby trunk - Feature #11761] `Hash#default_set` and `Hash#default_proc_set` Issue #11761 has been updated by Tsuyoshi Sawada. Or, perhaps there should be just one method `Hash#default_set` that can take either an argument or a block: h.default_set(default_value)... h.default_set{default_proc_value}... ---------------------------------------- Feature #11761: `Hash#default_set` and `Hash#default_proc_set` https://bugs.ruby-lang.org/issues/11761#change-55203 * Author: Tsuyoshi Sawada * Status: Open * Priority: Normal * Assignee: ---------------------------------------- I often want to assign a default value or proc to an existing hash `h` and chain method after it. The way I do it is: Hash.new(default_value).merge(h)... Hash.new{default_proc_value}.merge(h)... It would be convenient if I can assign them to a hash directly, and `Hash#default=` and `Hash#default_proc=` are close to doing that, but they are actually not useful because the return value is not the receiver hash: h.default = default_value; h... h.default_proc = proc {default_proc_value}; h... I wish there were methods `Hash#default_set` and `Hash#default_proc_set` that return the receiver hash: h.default_set(default_value)... h.default_proc_set{default_proc_value}... -- https://bugs.ruby-lang.org/