Skip to content

Commit a5e1d54

Browse files
committed
[DOC] Mention the edge case of any?/all?
1 parent a16cffe commit a5e1d54

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

array.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7768,6 +7768,9 @@ rb_ary_drop_while(VALUE ary)
77687768
*
77697769
* Returns +true+ if any element of +self+ meets a given criterion.
77707770
*
7771+
* If +self+ has no element, returns +false+ and argument or block
7772+
* are not used.
7773+
*
77717774
* With no block given and no argument, returns +true+ if +self+ has any truthy element,
77727775
* +false+ otherwise:
77737776
*
@@ -7829,6 +7832,9 @@ rb_ary_any_p(int argc, VALUE *argv, VALUE ary)
78297832
*
78307833
* Returns +true+ if all elements of +self+ meet a given criterion.
78317834
*
7835+
* If +self+ has no element, returns +true+ and argument or block
7836+
* are not used.
7837+
*
78327838
* With no block given and no argument, returns +true+ if +self+ contains only truthy elements,
78337839
* +false+ otherwise:
78347840
*

enum.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,6 +1757,9 @@ DEFINE_ENUMFUNCS(all)
17571757
*
17581758
* Returns whether every element meets a given criterion.
17591759
*
1760+
* If +self+ has no element, returns +true+ and argument or block
1761+
* are not used.
1762+
*
17601763
* With no argument and no block,
17611764
* returns whether every element is truthy:
17621765
*
@@ -1818,6 +1821,9 @@ DEFINE_ENUMFUNCS(any)
18181821
*
18191822
* Returns whether any element meets a given criterion.
18201823
*
1824+
* If +self+ has no element, returns +false+ and argument or block
1825+
* are not used.
1826+
*
18211827
* With no argument and no block,
18221828
* returns whether any element is truthy:
18231829
*
@@ -1848,7 +1854,6 @@ DEFINE_ENUMFUNCS(any)
18481854
* {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true
18491855
* {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false
18501856
*
1851-
*
18521857
* Related: #all?, #none?, #one?.
18531858
*/
18541859

hash.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4432,6 +4432,9 @@ any_p_i_pattern(VALUE key, VALUE value, VALUE arg)
44324432
* Returns +true+ if any element satisfies a given criterion;
44334433
* +false+ otherwise.
44344434
*
4435+
* If +self+ has no element, returns +false+ and argument or block
4436+
* are not used.
4437+
*
44354438
* With no argument and no block,
44364439
* returns +true+ if +self+ is non-empty; +false+ if empty.
44374440
*
@@ -4450,6 +4453,8 @@ any_p_i_pattern(VALUE key, VALUE value, VALUE arg)
44504453
* h = {foo: 0, bar: 1, baz: 2}
44514454
* h.any? {|key, value| value < 3 } # => true
44524455
* h.any? {|key, value| value > 3 } # => false
4456+
*
4457+
* Related: Enumerable#any?
44534458
*/
44544459

44554460
static VALUE

0 commit comments

Comments
 (0)