Skip to content

Commit fcc9d7e

Browse files
committed
perldelta for any() + all()
1 parent 6f04944 commit fcc9d7e

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
@@ -41,6 +41,31 @@ similar to the way that C<:reader> already creates reader accessors.
4141
my $p = Point->new( x => 20, y => 40 );
4242
$p->set_x(60);
4343

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

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

0 commit comments

Comments
 (0)