Skip to content

Commit

Permalink
Clarify the behavior of Any.join and List.join
Browse files Browse the repository at this point in the history
Somebody on IRC asked how to customize the way join treats the elements.
The documentation merely stated that the elements were treated as
strings, but not how this happens. This patch clarifies that .Str is
called. Also clarify how Any.join calls self.list first.
  • Loading branch information
chloekek committed Jul 30, 2019
1 parent 3569484 commit eefd0f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions doc/Type/Any.pod6
Expand Up @@ -913,9 +913,10 @@ Defined as
method join($separator = '') is nodal
Converts the object to a list, and applies
L<C<list.join>|/type/List#routine_join> to it. Can take a separator, which is an
empty string by default.
Converts the object to a list by calling
L<C<self.list>|/type/Any#routine_list>,
and calls L<C<.join>|/type/List#routine_join> on the list.
Can take a separator, which is an empty string by default.
(1..3).join.say ; # OUTPUT: «123␤»
<a b c>.join("❧").put; # OUTPUT: «a❧b❧c␤»
Expand Down
7 changes: 4 additions & 3 deletions doc/Type/List.pod6
Expand Up @@ -235,9 +235,10 @@ Defined as:
sub join($separator, *@list)
method join(List:D: $separator = "")
Treats the elements of the list as strings, interleaves them with
C<$separator> and concatenates everything into a single string. Note that
you can omit the C<$separator> if you use the method syntax.
Treats the elements of the list as strings by calling
L<C<.Str>|/type/Any#routine_Str> on each of them, interleaves them with
C<$separator> and concatenates everything into a single string. Note that you
can omit the C<$separator> if you use the method syntax.
Example:
Expand Down

0 comments on commit eefd0f3

Please sign in to comment.