[DOC] Tweaks for Hash#to_proc

This commit is contained in:
BurdetteLamar 2025-03-12 14:37:38 -05:00 committed by Peter Zhu
parent ae7890df33
commit 057ee25d1b
Notes: git 2025-03-14 01:12:04 +00:00

3
hash.c
View File

@ -4817,12 +4817,15 @@ hash_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(key, hash))
* to_proc -> proc
*
* Returns a Proc object that maps a key to its value:
*
* h = {foo: 0, bar: 1, baz: 2}
* proc = h.to_proc
* proc.class # => Proc
* proc.call(:foo) # => 0
* proc.call(:bar) # => 1
* proc.call(:nosuch) # => nil
*
* Related: see {Methods for Converting}[rdoc-ref:Hash@Methods+for+Converting].
*/
static VALUE
rb_hash_to_proc(VALUE hash)