summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-02-03 05:34:16 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-02-03 05:34:16 +0000
commit0c90036fd14fd5aef136afccfb38e42c4d3c01e3 (patch)
treeb7b065aabe639d272c8e53defbe59daac51bbf23 /hash.c
parente58e5cb5caf8aeac402ebe2db617c20beca2c0eb (diff)
* re.c (rb_memsearch): algolithm body of String#index.
* error.c (Init_Exception): "to_str" removed. * eval.c (eval): should not rely on Exception#to_str * eval.c (compile_error): ditto. * error.c (err_append): ditto. * hash.c (rb_hash_merge): Hash#merge, non destructive "update". now there's also Hash#merge! which is an alias to "update". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index 249bc64..d52ef7a 100644
--- a/hash.c
+++ b/hash.c
@@ -937,6 +937,13 @@ rb_hash_update(hash1, hash2)
return hash1;
}
+static VALUE
+rb_hash_merge(hash1, hash2)
+ VALUE hash1, hash2;
+{
+ return rb_hash_update(rb_obj_dup(hash1), hash2);
+}
+
static int path_tainted = -1;
static char **origenviron;
@@ -1743,6 +1750,8 @@ Init_Hash()
rb_define_method(rb_cHash,"invert", rb_hash_invert, 0);
rb_define_method(rb_cHash,"update", rb_hash_update, 1);
rb_define_method(rb_cHash,"replace", rb_hash_replace, 1);
+ rb_define_method(rb_cHash,"merge!", rb_hash_update, 1);
+ rb_define_method(rb_cHash,"merge", rb_hash_merge, 1);
rb_define_method(rb_cHash,"include?", rb_hash_has_key, 1);
rb_define_method(rb_cHash,"member?", rb_hash_has_key, 1);