From eefd0f3c103ebf1a326e4060bd6090c2dae40f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9?= Date: Tue, 30 Jul 2019 21:21:01 +0200 Subject: [PATCH] Clarify the behavior of Any.join and List.join 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. --- doc/Type/Any.pod6 | 7 ++++--- doc/Type/List.pod6 | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/Type/Any.pod6 b/doc/Type/Any.pod6 index ac1ac6644..b2e27d5a5 100644 --- a/doc/Type/Any.pod6 +++ b/doc/Type/Any.pod6 @@ -913,9 +913,10 @@ Defined as method join($separator = '') is nodal -Converts the object to a list, and applies -L|/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|/type/Any#routine_list>, +and calls L|/type/List#routine_join> on the list. +Can take a separator, which is an empty string by default. (1..3).join.say ; # OUTPUT: «123␤» .join("❧").put; # OUTPUT: «a❧b❧c␤» diff --git a/doc/Type/List.pod6 b/doc/Type/List.pod6 index bf3adca3f..9df0f6697 100644 --- a/doc/Type/List.pod6 +++ b/doc/Type/List.pod6 @@ -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|/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: