Skip to content

Commit 39014d6

Browse files
committed
show how to test for empty list in the part that readers will actually
read
1 parent 3481ba8 commit 39014d6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/Type/List.pod6

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ check for the absence of elements.
7474
}
7575
# OUTPUT«True␤True␤True␤»
7676
77+
Coercion to Bool also indicates if the List got any elements.
78+
79+
my @a;
80+
say [@a.elems, @a.Bool, ?@a];
81+
@a.push: 42;
82+
say [@a.elems, @a.Bool, ?@a];
83+
say 'empty' unless @a;
84+
# OUTPUT«[0 False False]␤[1 True True]␤»
85+
7786
=head1 Methods
7887
7988
=head2 routine elems

0 commit comments

Comments
 (0)