diff options
| author | BurdetteLamar <burdettelamar@yahoo.com> | 2025-03-16 16:07:11 -0500 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2025-03-23 11:07:31 -0400 |
| commit | 383af53a56f7e4a490b891701f96f91ef31e0bef (patch) | |
| tree | 0aa77c5860820be740b16f932bd5322af8dd6a64 | |
| parent | 7e0dac4cb18be87600068c346cd5339d1d880f01 (diff) | |
[DOC] Doc for Hash#transform_values
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12943
| -rw-r--r-- | hash.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -3403,20 +3403,18 @@ transform_values_foreach_replace(st_data_t *key, st_data_t *value, st_data_t arg * transform_values {|value| ... } -> new_hash * transform_values -> new_enumerator * - * Returns a new +Hash+ object; each entry has: - * * A key from +self+. - * * A value provided by the block. + * With a block given, returns a new hash +new_hash+; + * for each pair +key+/+value+ in +self+, + * calls the block with +value+ and captures its return as +new_value+; + * adds to +new_hash+ the entry +key+/+new_value+: * - * Transform values: * h = {foo: 0, bar: 1, baz: 2} * h1 = h.transform_values {|value| value * 100} * h1 # => {foo: 0, bar: 100, baz: 200} * - * Returns a new Enumerator if no block given: - * h = {foo: 0, bar: 1, baz: 2} - * e = h.transform_values # => #<Enumerator: {foo: 0, bar: 1, baz: 2}:transform_values> - * h1 = e.each { |value| value * 100} - * h1 # => {foo: 0, bar: 100, baz: 200} + * With no block given, returns a new Enumerator. + * + * Related: see {Methods for Transforming Keys and Values}[rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values]. */ static VALUE rb_hash_transform_values(VALUE hash) |
