File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,31 @@ similar to the way that C<:reader> already creates reader accessors.
41
41
my $p = Point->new( x => 20, y => 40 );
42
42
$p->set_x(60);
43
43
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
+
44
69
=head1 Security
45
70
46
71
XXX Any security-related notices go here. In particular, any security
You can’t perform that action at this time.
0 commit comments