mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 10:03:59 +02:00
[DOC] Tweaks for Hash#assoc (#12726)
This commit is contained in:
parent
57b9b92193
commit
7fd589c7fc
Notes:
git
2025-02-10 19:31:59 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>
1 changed files with 5 additions and 3 deletions
8
hash.c
8
hash.c
|
@ -4158,13 +4158,15 @@ assoc_i(VALUE key, VALUE val, VALUE arg)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* hash.assoc(key) -> new_array or nil
|
* assoc(key) -> entry or nil
|
||||||
|
*
|
||||||
|
* If the given +key+ is found, returns its entry as a 2-element array
|
||||||
|
* containing that key and its value:
|
||||||
*
|
*
|
||||||
* If the given +key+ is found, returns a 2-element Array containing that key and its value:
|
|
||||||
* h = {foo: 0, bar: 1, baz: 2}
|
* h = {foo: 0, bar: 1, baz: 2}
|
||||||
* h.assoc(:bar) # => [:bar, 1]
|
* h.assoc(:bar) # => [:bar, 1]
|
||||||
*
|
*
|
||||||
* Returns +nil+ if key +key+ is not found.
|
* Returns +nil+ if the key is not found.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue