Skip to content

Commit 69fd8a9

Browse files
committed
* hash.c (Hash#merge doc): Added explanation for form with block.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent c3c8c1e commit 69fd8a9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

hash.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
17151715
* hsh.update(other_hash){|key, oldval, newval| block} => hsh
17161716
*
17171717
* Adds the contents of <i>other_hash</i> to <i>hsh</i>. If no
1718-
* block is specified entries with duplicate keys are overwritten
1718+
* block is specified, entries with duplicate keys are overwritten
17191719
* with the values from <i>other_hash</i>, otherwise the value
17201720
* of each duplicate key is determined by calling the block with
17211721
* the key, its value in <i>hsh</i> and its value in <i>other_hash</i>.
@@ -1750,12 +1750,16 @@ rb_hash_update(VALUE hash1, VALUE hash2)
17501750
* hsh.merge(other_hash){|key, oldval, newval| block} -> a_hash
17511751
*
17521752
* Returns a new hash containing the contents of <i>other_hash</i> and
1753-
* the contents of <i>hsh</i>, overwriting entries in <i>hsh</i> with
1754-
* duplicate keys with those from <i>other_hash</i>.
1753+
* the contents of <i>hsh</i>. If no block is specified, the value for
1754+
* entries with duplicate keys will be that of <i>other_hash</i>. Otherwise
1755+
* the value for each duplicate key is determined by calling the block
1756+
* with the key, its value in <i>hsh</i> and its value in <i>other_hash</i>.
17551757
*
17561758
* h1 = { "a" => 100, "b" => 200 }
17571759
* h2 = { "b" => 254, "c" => 300 }
17581760
* h1.merge(h2) #=> {"a"=>100, "b"=>254, "c"=>300}
1761+
* h1.merge(h2){|key, oldval, newval| newval - oldval}
1762+
* #=> {"a"=>100, "b"=>54, "c"=>300}
17591763
* h1 #=> {"a"=>100, "b"=>200}
17601764
*
17611765
*/

0 commit comments

Comments
 (0)