summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-19 09:42:27 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-19 09:42:27 +0000
commit87316940b98d5a55245cf9347000ded6be791c55 (patch)
tree0fb4567a00f2dc5eac87719d6571def2e2cfaabb /hash.c
parent158e1367e5dfc5a675c93cdad8a0c2a0224eaa2d (diff)
* intern.h, hash.c (rb_hash_lookup): New internal function to
check if a key exists in a hash, ignoring #default; backported from 1.9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index 863c98924b..f7ad09032b 100644
--- a/hash.c
+++ b/hash.c
@@ -454,6 +454,18 @@ rb_hash_aref(hash, key)
return val;
}
+VALUE
+rb_hash_lookup(hash, key)
+ VALUE hash, key;
+{
+ VALUE val;
+
+ if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
+ return Qnil; /* without Hash#default */
+ }
+ return val;
+}
+
/*
* call-seq:
* hsh.fetch(key [, default] ) => obj