mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[DOC] Tweaks for Hash#invert
This commit is contained in:
parent
43a729b1be
commit
3bbb029d44
Notes:
git
2025-02-26 14:29:10 +00:00
Merged: https://github.com/ruby/ruby/pull/12808 Merged-By: peterzhu2118 <peter@peterzhu.ca>
1 changed files with 6 additions and 2 deletions
8
hash.c
8
hash.c
|
@ -3938,15 +3938,19 @@ rb_hash_invert_i(VALUE key, VALUE value, VALUE hash)
|
|||
* call-seq:
|
||||
* invert -> new_hash
|
||||
*
|
||||
* Returns a new +Hash+ object with the each key-value pair inverted:
|
||||
* Returns a new hash with each key-value pair inverted:
|
||||
*
|
||||
* h = {foo: 0, bar: 1, baz: 2}
|
||||
* h1 = h.invert
|
||||
* h1 # => {0=>:foo, 1=>:bar, 2=>:baz}
|
||||
*
|
||||
* Overwrites any repeated new keys:
|
||||
* Overwrites any repeated new keys
|
||||
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
|
||||
*
|
||||
* h = {foo: 0, bar: 0, baz: 0}
|
||||
* h.invert # => {0=>:baz}
|
||||
*
|
||||
* Related: see {Methods for Transforming Keys and Values}[rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values].
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue