Skip to content

Commit e645f40

Browse files
committed
perldelta
1 parent 7e7e80e commit e645f40

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pod/perldelta.pod

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ here, but most should go in the L</Performance Enhancements> section.
2727

2828
[ List each enhancement as a =head2 entry ]
2929

30+
=head2 New C<any> and C<all> operators
31+
32+
A new experimental feature has been added, which adds two new list-processing
33+
operators, C<any> and C<all>.
34+
35+
use v5.40;
36+
use feature 'any_all';
37+
38+
my @numbers = ...
39+
40+
if(all { $_ % 2 == 0 } @numbers) {
41+
say "All the numbers are even";
42+
}
43+
44+
These operate similarly to C<grep> except that they only ever return true or
45+
false, testing if any (or all) of the elements in the list make the testing
46+
block yield true. Because of this they can short-circuit, avoiding the need
47+
to test any further elements if a given element determines the eventual
48+
result.
49+
50+
These are inspired by the same-named functions in the L<List::Util> module,
51+
except that they are implemented as direct core operators, and thus perform
52+
faster, and do not produce an additional subroutine call stack frame for
53+
invoking the code block.
54+
3055
=head1 Security
3156

3257
XXX Any security-related notices go here. In particular, any security

0 commit comments

Comments
 (0)