[DOC] Tweaks for Hash#invert

This commit is contained in:
Burdette Lamar 2025-02-26 08:28:52 -06:00 committed by GitHub
parent 43a729b1be
commit 3bbb029d44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
Notes: git 2025-02-26 14:29:10 +00:00
Merged: https://github.com/ruby/ruby/pull/12808

Merged-By: peterzhu2118 <peter@peterzhu.ca>

8
hash.c
View file

@ -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