summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-08 08:54:01 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-08 08:54:01 +0000
commit320e99d8dda5eb5fc327fcbe20126cdd7fcd059d (patch)
treeb1fc6d8062eebd46c7b8f4fd67f606c9af8f93c2 /hash.c
parent25be6ce9b5dd2aabad61410068d688250c562189 (diff)
2000-02-08
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index 77f7e3e..4e3cf99 100644
--- a/hash.c
+++ b/hash.c
@@ -476,6 +476,13 @@ rb_hash_delete_if(hash)
return hash;
}
+static VALUE
+rb_hash_reject(hash)
+ VALUE hash;
+{
+ return rb_hash_delete_if(rb_hash_dup(hash));
+}
+
static int
clear_i(key, value, dummy)
VALUE key, value, dummy;
@@ -1211,6 +1218,12 @@ env_delete_if()
}
static VALUE
+env_reject()
+{
+ return rb_hash_delete_if(env_to_hash());
+}
+
+static VALUE
env_to_s()
{
return rb_str_new2("ENV");
@@ -1331,8 +1344,7 @@ env_indexes(argc, argv)
}
static VALUE
-env_to_hash(obj)
- VALUE obj;
+env_to_hash()
{
char **env;
VALUE hash = rb_hash_new();
@@ -1397,6 +1409,7 @@ Init_Hash()
rb_define_method(rb_cHash,"delete", rb_hash_delete, 1);
rb_define_method(rb_cHash,"delete_if", rb_hash_delete_if, 0);
rb_define_method(rb_cHash,"reject!", rb_hash_delete_if, 0);
+ rb_define_method(rb_cHash,"reject", rb_hash_reject, 0);
rb_define_method(rb_cHash,"clear", rb_hash_clear, 0);
rb_define_method(rb_cHash,"invert", rb_hash_invert, 0);
rb_define_method(rb_cHash,"update", rb_hash_update, 1);
@@ -1423,6 +1436,7 @@ Init_Hash()
rb_define_singleton_method(envtbl,"delete", env_delete_m, 1);
rb_define_singleton_method(envtbl,"delete_if", env_delete_if, 0);
rb_define_singleton_method(envtbl,"reject!", env_delete_if, 0);
+ rb_define_singleton_method(envtbl,"reject", env_reject, 0);
rb_define_singleton_method(envtbl,"to_s", env_to_s, 0);
rb_define_singleton_method(envtbl,"rehash", env_none, 0);
rb_define_singleton_method(envtbl,"to_a", env_to_a, 0);