summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-23 02:18:52 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-23 02:18:52 (GMT)
commit96db72ce38b27799dd8e80ca00696e41234db6ba (patch)
tree4c210692772faf26ed8ddac746dc79aec0240e2d /hash.c
parentb9d01e225723b3dfb6e18d0dcb790c20fef78d63 (diff)
[DOC] missing docs at toplevel
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index 85c6e85..d2ca057 100644
--- a/hash.c
+++ b/hash.c
@@ -3186,6 +3186,19 @@ hash_proc_call(VALUE key, VALUE hash, int argc, const VALUE *argv, VALUE passed_
return rb_hash_aref(hash, *argv);
}
+/*
+ * call-seq:
+ * hash.to_proc -> proc
+ *
+ * Returns a Proc which maps keys to values.
+ *
+ * h = {a:1, b:2}
+ * hp = h.to_proc
+ * hp.call(:a) #=> 1
+ * hp.call(:b) #=> 2
+ * hp.call(:c) #=> nil
+ * [:a, :b, :c].map(&h) #=> [1, 2, nil]
+ */
static VALUE
rb_hash_to_proc(VALUE hash)
{