Skip to content

Commit b52f789

Browse files
[DOC] Tweaks for Hash#select! (#12904)
1 parent a5f2921 commit b52f789

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

hash.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,16 +2809,19 @@ rb_hash_select(VALUE hash)
28092809
* select! {|key, value| ... } -> self or nil
28102810
* select! -> new_enumerator
28112811
*
2812-
* Returns +self+, whose entries are those for which the block returns a truthy value:
2813-
* h = {foo: 0, bar: 1, baz: 2}
2814-
* h.select! {|key, value| value < 2 } => {foo: 0, bar: 1}
2812+
* With a block given, calls the block with each entry's key and value;
2813+
* removes from +self+ each entry for which the block returns +false+ or +nil+.
28152814
*
2816-
* Returns +nil+ if no entries were removed.
2815+
* Returns +self+ if any entries were removed, +nil+ otherwise:
28172816
*
2818-
* Returns a new Enumerator if no block given:
28192817
* h = {foo: 0, bar: 1, baz: 2}
2820-
* e = h.select! # => #<Enumerator: {foo: 0, bar: 1, baz: 2}:select!>
2821-
* e.each { |key, value| value < 2 } # => {foo: 0, bar: 1}
2818+
* h.select! {|key, value| value < 2 } # => {foo: 0, bar: 1}
2819+
* h.select! {|key, value| value < 2 } # => nil
2820+
*
2821+
*
2822+
* With no block given, returns a new Enumerator.
2823+
*
2824+
* Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
28222825
*/
28232826

28242827
static VALUE

0 commit comments

Comments
 (0)