Skip to content

Commit 11bd102

Browse files
committed
Document List.ACCEPTS
1 parent 7728d81 commit 11bd102

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

doc/Type/List.pod6

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,38 @@ Coercion to C<Bool> also indicates if the C<List> got any elements.
8484
8585
=head1 Methods
8686
87+
=head2 method ACCEPTS
88+
89+
Defined as:
90+
91+
multi method ACCEPTS(List:D: $topic)
92+
93+
If C<$topic> is an L<Iterable>, returns C<True> or C<False> based on whether
94+
the contents of the two C<Iterables> match. A L<Whatever> element in the
95+
invocant matches anything in the corresponding position of the C<$topic>
96+
C<Iterable>. A L<HyperWhatever> matches any number of any elements, including
97+
no elements:
98+
99+
say (1, 2, 3) ~~ (1, *, 3); # OUTPUT: «True␤»
100+
say (1, 2, 3) ~~ (9, *, 5); # OUTPUT: «False␤»
101+
say (1, 2, 3) ~~ ( **, 3); # OUTPUT: «True␤»
102+
say (1, 2, 3) ~~ ( **, 5); # OUTPUT: «False␤»
103+
say (1, 3) ~~ (1, **, 3); # OUTPUT: «True␤»
104+
say (1, 2, 4, 5, 3) ~~ (1, **, 3); # OUTPUT: «True␤»
105+
say (1, 2, 4, 5, 6) ~~ (1, **, 5); # OUTPUT: «False␤»
106+
say (1, 2, 4, 5, 6) ~~ ( ** ); # OUTPUT: «True␤»
107+
say () ~~ ( ** ); # OUTPUT: «True␤»
108+
109+
In addition, returns C<False> if either the invocant or C<$topic>
110+
L<is a lazy|/routine/is-lazy> C<Iterable>, unless C<$topic> is the same object
111+
as the invocant, in which case C<True> is returned.
112+
113+
If C<$topic> is I<not> an L<Iterable>, returns the invocant if the ivocant
114+
has no elements or its first element is a L<Match> object (this behaviour
115+
powers C<m:g//> smartmatch), or C<False> otherwise.
116+
117+
=item1 C
118+
87119
=head2 routine elems
88120
89121
Defined as:

0 commit comments

Comments
 (0)