Skip to content

Commit

Permalink
Elaborate a bit in array/hash interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jun 12, 2018
1 parent 5794616 commit f6328ae
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions doc/Language/5to6-perlop.pod6
Expand Up @@ -285,13 +285,15 @@ get this behavior with single quotes.
C<qq> allows interpolation of variables. However, by default, only
scalar variables are interpolated. To get other variables to
interpolate, you need to put square brackets after them. E. g. C<< @a =
<1 2 3>;say qq/@a[] example@example.com/; >> results in "1 2 3
example@example.com". Hashes interpolate in a possibly unexpected
manner: C<< %a = 1 => 2, 3 => 4;say "%a[]"; >> results in a space
interpolate, you need to put square brackets after them (the so-called
L<zen-slice|/language/subscripts#index-entry-Zen_slices>) to get them to
interpolate. E.g. C<< @a = <1 2 3>; say qq/@a[] example@example.com/; >>
results in "1 2 3 example@example.com". Hashes interpolate in the same
manner: C<< %a = 1 => 2, 3 => 4;say "%a{}"; >> results in a space
separating the pairs and tabs separating the key from the value in each
pair (apparently). You can also interpolate Perl 6 code in strings using
curly braces. For all the details, see
pair (because that's the standard stringification of C<Pair>s, and a hash
acts as list of C<Pair>s when stringified). You can also interpolate Perl 6
code in strings using curly braces. For all the details, see
L<Interpolation|/language/quoting#Interpolation%3A_qq>.
C<qw> works as in Perl 5, and can also be rendered as C<< <...> >>. E.
Expand Down

0 comments on commit f6328ae

Please sign in to comment.