Skip to content

Commit cbe5241

Browse files
committed
[DOC] Mention that Hash#replace also replaces defaults
1 parent e2fbd01 commit cbe5241

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

hash.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,14 @@ rb_hash_aset(VALUE hash, VALUE key, VALUE val)
29872987
* h = {foo: 0, bar: 1, baz: 2}
29882988
* h.replace({bat: 3, bam: 4}) # => {bat: 3, bam: 4}
29892989
*
2990+
* Also replaces the default value or proc of +self+ with the default value
2991+
* or proc of +other_hash+.
2992+
*
2993+
* h = {}
2994+
* other = Hash.new(:ok)
2995+
* h.replace(other)
2996+
* h.default # => :ok
2997+
*
29902998
* Related: see {Methods for Assigning}[rdoc-ref:Hash@Methods+for+Assigning].
29912999
*/
29923000

0 commit comments

Comments
 (0)