summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index b2008350c..194e4e538 100644
--- a/hash.c
+++ b/hash.c
@@ -401,6 +401,17 @@ rb_hash_aref(VALUE hash, VALUE key)
return val;
}
+VALUE
+rb_hash_lookup(VALUE hash, VALUE 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