[DOC] Tweaks for Hash#assoc (#12726)

This commit is contained in:
Burdette Lamar 2025-02-10 13:31:41 -06:00 committed by GitHub
parent 57b9b92193
commit 7fd589c7fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-02-10 19:31:59 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>

8
hash.c
View File

@ -4158,13 +4158,15 @@ assoc_i(VALUE key, VALUE val, VALUE arg)
/*
* 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.assoc(:bar) # => [:bar, 1]
*
* Returns +nil+ if key +key+ is not found.
* Returns +nil+ if the key is not found.
*/
static VALUE