1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Added sample code of merge! method in hash.c.

https://github.com/ruby/ruby/pull/1652

  Patch by @selmertsx [fix GH-1652]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2017-10-21 13:40:12 +00:00
parent 3e95ecd8d1
commit ec4141f183

2
hash.c
View file

@ -2530,11 +2530,13 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
* h1 = { "a" => 100, "b" => 200 } * h1 = { "a" => 100, "b" => 200 }
* h2 = { "b" => 254, "c" => 300 } * h2 = { "b" => 254, "c" => 300 }
* h1.merge!(h2) #=> {"a"=>100, "b"=>254, "c"=>300} * h1.merge!(h2) #=> {"a"=>100, "b"=>254, "c"=>300}
* h1 #=> {"a"=>100, "b"=>254, "c"=>300}
* *
* h1 = { "a" => 100, "b" => 200 } * h1 = { "a" => 100, "b" => 200 }
* h2 = { "b" => 254, "c" => 300 } * h2 = { "b" => 254, "c" => 300 }
* h1.merge!(h2) { |key, v1, v2| v1 } * h1.merge!(h2) { |key, v1, v2| v1 }
* #=> {"a"=>100, "b"=>200, "c"=>300} * #=> {"a"=>100, "b"=>200, "c"=>300}
* h1 #=> {"a"=>100, "b"=>200, "c"=>300}
*/ */
static VALUE static VALUE