[DOC] Tweaks for Hash#each_key

This commit is contained in:
BurdetteLamar 2025-02-18 08:51:37 -06:00 committed by Peter Zhu
parent e9ba334fd1
commit eafcdc1535
Notes: git 2025-02-18 15:05:15 +00:00

16
hash.c
View File

@ -3078,23 +3078,19 @@ each_key_i(VALUE key, VALUE value, VALUE _)
* each_key {|key| ... } -> self * each_key {|key| ... } -> self
* each_key -> new_enumerator * each_key -> new_enumerator
* *
* Calls the given block with each key; returns +self+: * With a block given, calls the block with each key; returns +self+:
*
* h = {foo: 0, bar: 1, baz: 2} * h = {foo: 0, bar: 1, baz: 2}
* h.each_key {|key| puts key } # => {foo: 0, bar: 1, baz: 2} * h.each_key {|key| puts key } # => {foo: 0, bar: 1, baz: 2}
*
* Output: * Output:
* foo * foo
* bar * bar
* baz * baz
* *
* 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_key # => #<Enumerator: {foo: 0, bar: 1, baz: 2}:each_key> * Related: see {Methods for Iterating}[rdoc-ref:Hash@Methods+for+Iterating].
* h1 = e.each {|key| puts key }
* h1 # => {foo: 0, bar: 1, baz: 2}
* Output:
* foo
* bar
* baz
*/ */
static VALUE static VALUE
rb_hash_each_key(VALUE hash) rb_hash_each_key(VALUE hash)