summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-06 17:03:48 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-06 17:03:48 +0000
commit69fd8a9011b7a3a911b9546104ce6acb962a4a94 (patch)
tree8b7fbc1feff27dda4ea7450613bb674cf1475872 /hash.c
parentc3c8c1e37c6fe0c032e079d1f61ce2a00df02b4d (diff)
* 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
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index 5eba21654e..dda685012c 100644
--- a/hash.c
+++ b/hash.c
@@ -1715,7 +1715,7 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
* hsh.update(other_hash){|key, oldval, newval| block} => hsh
*
* Adds the contents of <i>other_hash</i> to <i>hsh</i>. If no
- * block is specified entries with duplicate keys are overwritten
+ * block is specified, entries with duplicate keys are overwritten
* with the values from <i>other_hash</i>, otherwise the value
* of each duplicate key is determined by calling the block with
* 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)
* hsh.merge(other_hash){|key, oldval, newval| block} -> a_hash
*
* Returns a new hash containing the contents of <i>other_hash</i> and
- * the contents of <i>hsh</i>, overwriting entries in <i>hsh</i> with
- * duplicate keys with those from <i>other_hash</i>.
+ * the contents of <i>hsh</i>. If no block is specified, the value for
+ * entries with duplicate keys will be that of <i>other_hash</i>. Otherwise
+ * the value for each duplicate key is determined by calling the block
+ * with the key, its value in <i>hsh</i> and its value in <i>other_hash</i>.
*
* h1 = { "a" => 100, "b" => 200 }
* h2 = { "b" => 254, "c" => 300 }
* h1.merge(h2) #=> {"a"=>100, "b"=>254, "c"=>300}
+ * h1.merge(h2){|key, oldval, newval| newval - oldval}
+ * #=> {"a"=>100, "b"=>54, "c"=>300}
* h1 #=> {"a"=>100, "b"=>200}
*
*/