mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[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
1 changed files with 3 additions and 0 deletions
3
hash.c
3
hash.c
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue