[DOC] Tweaks for Hash#[]= (#12695)
This commit is contained in:
parent
8cafa5b8ce
commit
9be6e4207b
Notes:
git
2025-02-14 20:55:28 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>
23
hash.c
23
hash.c
@ -2900,26 +2900,31 @@ NOINSERT_UPDATE_CALLBACK(hash_aset_str)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* hash[key] = value -> value
|
* self[key] = object -> object
|
||||||
* store(key, value)
|
|
||||||
*
|
*
|
||||||
* Associates the given +value+ with the given +key+; returns +value+.
|
* Associates the given +object+ with the given +key+; returns +object+.
|
||||||
*
|
*
|
||||||
* If the given +key+ exists, replaces its value with the given +value+;
|
* Searches for a hash key equivalent to the given +key+;
|
||||||
|
* see {Hash Key Equivalence}[rdoc-ref:Hash@Hash+Key+Equivalence].
|
||||||
|
*
|
||||||
|
* If the key is found, replaces its value with the given +object+;
|
||||||
* the ordering is not affected
|
* the ordering is not affected
|
||||||
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
|
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
|
||||||
|
*
|
||||||
* h = {foo: 0, bar: 1}
|
* h = {foo: 0, bar: 1}
|
||||||
* h[:foo] = 2 # => 2
|
* h[:foo] = 2 # => 2
|
||||||
* h.store(:bar, 3) # => 3
|
* h[:foo] # => 2
|
||||||
* h # => {foo: 2, bar: 3}
|
|
||||||
*
|
*
|
||||||
* If +key+ does not exist, adds the +key+ and +value+;
|
* If +key+ is not found, creates a new entry for the given +key+ and +object+;
|
||||||
* the new entry is last in the order
|
* the new entry is last in the order
|
||||||
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
|
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
|
||||||
|
*
|
||||||
* h = {foo: 0, bar: 1}
|
* h = {foo: 0, bar: 1}
|
||||||
* h[:baz] = 2 # => 2
|
* h[:baz] = 2 # => 2
|
||||||
* h.store(:bat, 3) # => 3
|
* h[:baz] # => 2
|
||||||
* h # => {foo: 0, bar: 1, baz: 2, bat: 3}
|
* h # => {:foo=>0, :bar=>1, :baz=>2}
|
||||||
|
*
|
||||||
|
* Related: #[]; see also {Methods for Assigning}[rdoc-ref:Hash@Methods+for+Assigning].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user