[DOC] Tweaks for Hash#each_value

This commit is contained in:
BurdetteLamar 2025-02-18 09:10:29 -06:00 committed by Peter Zhu
parent eafcdc1535
commit fd134cf6d2
Notes: git 2025-02-18 20:02:24 +00:00

16
hash.c
View File

@ -3039,23 +3039,19 @@ each_value_i(VALUE key, VALUE value, VALUE _)
* each_value {|value| ... } -> self * each_value {|value| ... } -> self
* each_value -> new_enumerator * each_value -> new_enumerator
* *
* Calls the given block with each value; returns +self+: * With a block given, calls the block with each value; returns +self+:
*
* h = {foo: 0, bar: 1, baz: 2} * h = {foo: 0, bar: 1, baz: 2}
* h.each_value {|value| puts value } # => {foo: 0, bar: 1, baz: 2} * h.each_value {|value| puts value } # => {foo: 0, bar: 1, baz: 2}
*
* Output: * Output:
* 0 * 0
* 1 * 1
* 2 * 2
* *
* Returns a new Enumerator if no block given: * With no block given, returns a new Enumerator.
* h = {foo: 0, bar: 1, baz: 2} *
* e = h.each_value # => #<Enumerator: {foo: 0, bar: 1, baz: 2}:each_value> * Related: see {Methods for Iterating}[rdoc-ref:Hash@Methods+for+Iterating].
* h1 = e.each {|value| puts value }
* h1 # => {foo: 0, bar: 1, baz: 2}
* Output:
* 0
* 1
* 2
*/ */
static VALUE static VALUE