summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index 044964c809..a058a00a91 100644
--- a/hash.c
+++ b/hash.c
@@ -463,16 +463,22 @@ rb_hash_aref(VALUE hash, VALUE key)
}
VALUE
-rb_hash_lookup(VALUE hash, VALUE key)
+rb_hash_lookup2(VALUE hash, VALUE key, VALUE def)
{
VALUE val;
if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
- return Qnil; /* without Hash#default */
+ return def; /* without Hash#default */
}
return val;
}
+VALUE
+rb_hash_lookup(VALUE hash, VALUE key)
+{
+ return rb_hash_lookup2(hash, key, Qnil);
+}
+
/*
* call-seq:
* hsh.fetch(key [, default] ) => obj