Skip to content

Commit f84804e

Browse files
committed
Point out corner case of all()
This is probably better said here than in traps.pod
1 parent ea35d8e commit f84804e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Type/Junction.pod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ Usage examples:
6161
my @primes_ending_in_1 = grep &is_prime & / 1$ /, 2..100;
6262
say @primes_ending_in_1; # 11 31 41 61 71
6363
64+
Special care should be taken when using C<all> with arguments that may
65+
produce an empty list:
66+
67+
my @a = ();
68+
so all(@a) # True, because there are 0 False's
69+
so all(@a, ?@a) # Does what you might have meant by the above
70+
so all(@a, True) # Explicit way to express the first example
71+
6472
Negated operators are special-cased when it comes to autothreading.
6573
C<$a !op $b> is rewritten internally as C<!($a op $b)>. The outer
6674
negation collapses any junctions, so the return value always a plain

0 commit comments

Comments
 (0)