[DOC] Tweaks for Hash#to_proc
This commit is contained in:
parent
ae7890df33
commit
057ee25d1b
Notes:
git
2025-03-14 01:12:04 +00:00
3
hash.c
3
hash.c
@ -4817,12 +4817,15 @@ hash_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(key, hash))
|
|||||||
* to_proc -> proc
|
* to_proc -> proc
|
||||||
*
|
*
|
||||||
* Returns a Proc object that maps a key to its value:
|
* Returns a Proc object that maps a key to its value:
|
||||||
|
*
|
||||||
* h = {foo: 0, bar: 1, baz: 2}
|
* h = {foo: 0, bar: 1, baz: 2}
|
||||||
* proc = h.to_proc
|
* proc = h.to_proc
|
||||||
* proc.class # => Proc
|
* proc.class # => Proc
|
||||||
* proc.call(:foo) # => 0
|
* proc.call(:foo) # => 0
|
||||||
* proc.call(:bar) # => 1
|
* proc.call(:bar) # => 1
|
||||||
* proc.call(:nosuch) # => nil
|
* proc.call(:nosuch) # => nil
|
||||||
|
*
|
||||||
|
* Related: see {Methods for Converting}[rdoc-ref:Hash@Methods+for+Converting].
|
||||||
*/
|
*/
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_hash_to_proc(VALUE hash)
|
rb_hash_to_proc(VALUE hash)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user