Skip to content

Commit f6328ae

Browse files
committed
Elaborate a bit in array/hash interpolation
1 parent 5794616 commit f6328ae

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

doc/Language/5to6-perlop.pod6

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,15 @@ get this behavior with single quotes.
285285
286286
C<qq> allows interpolation of variables. However, by default, only
287287
scalar variables are interpolated. To get other variables to
288-
interpolate, you need to put square brackets after them. E. g. C<< @a =
289-
<1 2 3>;say qq/@a[] example@example.com/; >> results in "1 2 3
290-
example@example.com". Hashes interpolate in a possibly unexpected
291-
manner: C<< %a = 1 => 2, 3 => 4;say "%a[]"; >> results in a space
288+
interpolate, you need to put square brackets after them (the so-called
289+
L<zen-slice|/language/subscripts#index-entry-Zen_slices>) to get them to
290+
interpolate. E.g. C<< @a = <1 2 3>; say qq/@a[] example@example.com/; >>
291+
results in "1 2 3 example@example.com". Hashes interpolate in the same
292+
manner: C<< %a = 1 => 2, 3 => 4;say "%a{}"; >> results in a space
292293
separating the pairs and tabs separating the key from the value in each
293-
pair (apparently). You can also interpolate Perl 6 code in strings using
294-
curly braces. For all the details, see
294+
pair (because that's the standard stringification of C<Pair>s, and a hash
295+
acts as list of C<Pair>s when stringified). You can also interpolate Perl 6
296+
code in strings using curly braces. For all the details, see
295297
L<Interpolation|/language/quoting#Interpolation%3A_qq>.
296298
297299
C<qw> works as in Perl 5, and can also be rendered as C<< <...> >>. E.

0 commit comments

Comments
 (0)