Skip to content

Commit 51e2ff1

Browse files
[DOC] Tweaks for Hash#reject!
1 parent 3278e3b commit 51e2ff1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

hash.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,17 +2579,18 @@ rb_hash_delete_if(VALUE hash)
25792579
* reject! {|key, value| ... } -> self or nil
25802580
* reject! -> new_enumerator
25812581
*
2582-
* Returns +self+, whose remaining entries are those
2583-
* for which the block returns +false+ or +nil+:
2582+
* With a block given, calls the block with each entry's key and value;
2583+
* removes the entry from +self+ if the block returns a truthy value.
2584+
*
2585+
* Return +self+ if any entries were removed, +nil+ otherwise:
2586+
*
25842587
* h = {foo: 0, bar: 1, baz: 2}
25852588
* h.reject! {|key, value| value < 2 } # => {baz: 2}
2589+
* h.reject! {|key, value| value < 2 } # => nil
25862590
*
2587-
* Returns +nil+ if no entries are removed.
2591+
* With no block given, returns a new Enumerator.
25882592
*
2589-
* Returns a new Enumerator if no block given:
2590-
* h = {foo: 0, bar: 1, baz: 2}
2591-
* e = h.reject! # => #<Enumerator: {foo: 0, bar: 1, baz: 2}:reject!>
2592-
* e.each {|key, value| key.start_with?('b') } # => {foo: 0}
2593+
* Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
25932594
*/
25942595

25952596
static VALUE

0 commit comments

Comments
 (0)