diff options
| author | Burdette Lamar <BurdetteLamar@Yahoo.com> | 2025-02-10 13:23:42 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-10 14:23:42 -0500 |
| commit | 35afc0d6e1bbbfc2d80d0cf997a2579c378f5632 (patch) | |
| tree | dad5163f0f06157e752236f542eaea4a2a8f5c28 | |
| parent | c7e35e5534018add3b783e871ca93e27b693842d (diff) | |
[DOC] Tweaks for Hash#any?
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12724
Merged-By: peterzhu2118 <peter@peterzhu.ca>
| -rw-r--r-- | hash.c | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -4512,35 +4512,40 @@ any_p_i_pattern(VALUE key, VALUE value, VALUE arg) /* * call-seq: * hash.any? -> true or false - * hash.any?(object) -> true or false + * hash.any?(entry) -> true or false * hash.any? {|key, value| ... } -> true or false * * Returns +true+ if any element satisfies a given criterion; * +false+ otherwise. * - * If +self+ has no element, returns +false+ and argument or block - * are not used. + * If +self+ has no element, returns +false+ and argument or block are not used; + * otherwise behaves as below. * * With no argument and no block, - * returns +true+ if +self+ is non-empty; +false+ if empty. + * returns +true+ if +self+ is non-empty, +false+ otherwise. * - * With argument +object+ and no block, + * With argument +entry+ and no block, * returns +true+ if for any key +key+ - * <tt>h.assoc(key) == object</tt>: + * <tt>self.assoc(key) == entry</tt>, +false+ otherwise: + * * h = {foo: 0, bar: 1, baz: 2} + * h.assoc(:bar) # => [:bar, 1] * h.any?([:bar, 1]) # => true * h.any?([:bar, 0]) # => false - * h.any?([:baz, 1]) # => false * - * With no argument and a block, + * With no argument and a block given, * calls the block with each key-value pair; - * returns +true+ if the block returns any truthy value, + * returns +true+ if the block returns a truthy value, * +false+ otherwise: + * * h = {foo: 0, bar: 1, baz: 2} * h.any? {|key, value| value < 3 } # => true * h.any? {|key, value| value > 3 } # => false * - * Related: Enumerable#any? + * With both argument +entry+ and a block given, + * issues a warning and ignores the block. + * + * Related: Enumerable#any? (which this method overrides). */ static VALUE |
