diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-19 09:42:27 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-19 09:42:27 +0000 |
commit | 87316940b98d5a55245cf9347000ded6be791c55 (patch) | |
tree | 0fb4567a00f2dc5eac87719d6571def2e2cfaabb /hash.c | |
parent | 158e1367e5dfc5a675c93cdad8a0c2a0224eaa2d (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.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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 |