Skip to content

Commit

Permalink
add trap of interating Str
Browse files Browse the repository at this point in the history
  • Loading branch information
gfldex committed Dec 10, 2015
1 parent f30444e commit ab6c33a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doc/Language/traps.pod
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ which is equivalent to
Here, C<tc> means "title case".
=head2 Strings are not iterable
There are methods that Str inherits from Any that work on iterables like lists. Interators on Strings contain one element that is the whole string. To use C<sort>, C<reverse> and friends, you need to split the string into a list first.
say "abc".reverse; # abc (what is wrong)
say "abc".comb.reverse.join; # cba
=head1 Adverbs and Precedence
Adverbs do have a precedence that may not follow the order of operators that is displayed on your screen. If two operators of equal precedence are followed by an adverb it will pick the first operator it find in the abstract syntax tree. Use paranteses to help Perl 6 to understand what you mean or use operators with looser precedence.
Expand Down

0 comments on commit ab6c33a

Please sign in to comment.