diff --git a/doc/Language/containers.pod6 b/doc/Language/containers.pod6 index 124583770..1c3f832c0 100644 --- a/doc/Language/containers.pod6 +++ b/doc/Language/containers.pod6 @@ -283,11 +283,20 @@ As hinted above, scalar containers prevent that flattening: my @a = 1, 2, 3; say f $@a, 4, 5; # OUTPUT: «3␤» -The C<@> character can also be used as a prefix to remove a scalar container: +The C<@> character can also be used as a prefix to coerce the argument to a list, thus removing a scalar container: my $x = (1, 2, 3); .say for @$x; # 3 iterations +However, the C«<>» is more appropriate to decontainerize items that aren't +lists: + + my $x = ^Inf .grep: *.is-prime; + say "$_ is prime" for @$x; # WRONG! List keeps values, thus leaking memory + say "$_ is prime" for $x<>; # RIGHT. Simply decont the Seq + + my $y := ^Inf .grep: *.is-prime; # Even better; no Scalars involved at all + Methods generally don't care whether their invocant is in a scalar, so my $x = (1, 2, 3);