Skip to content

Commit 497f409

Browse files
[DOC] Tweaks for Hash#reject (ruby#12876)
1 parent e990267 commit 497f409

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

hash.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,17 +2611,18 @@ rb_hash_reject_bang(VALUE hash)
26112611
* reject {|key, value| ... } -> new_hash
26122612
* reject -> new_enumerator
26132613
*
2614-
* Returns a new +Hash+ object whose entries are all those
2615-
* from +self+ for which the block returns +false+ or +nil+:
2616-
* h = {foo: 0, bar: 1, baz: 2}
2617-
* h1 = h.reject {|key, value| key.start_with?('b') }
2618-
* h1 # => {foo: 0}
2614+
* With a block given, returns a copy of +self+ with zero or more entries removed;
2615+
* calls the block with each key-value pair;
2616+
* excludes the entry in the copy if the block returns a truthy value,
2617+
* includes it otherwise:
26192618
*
2620-
* Returns a new Enumerator if no block given:
26212619
* h = {foo: 0, bar: 1, baz: 2}
2622-
* e = h.reject # => #<Enumerator: {foo: 0, bar: 1, baz: 2}:reject>
2623-
* h1 = e.each {|key, value| key.start_with?('b') }
2624-
* h1 # => {foo: 0}
2620+
* h.reject {|key, value| key.start_with?('b') }
2621+
* # => {foo: 0}
2622+
*
2623+
* With no block given, returns a new Enumerator.
2624+
*
2625+
* Related: see {Methods for Deleting}[rdoc-ref:Hash@Methods+for+Deleting].
26252626
*/
26262627

26272628
static VALUE

0 commit comments

Comments
 (0)