On 10/04/2017 12:48 PM, Andy Bach wrote:
 > I think maybe I don't understand how <<>> is used in a
and how <<>> differs from a ""

<<>> is quoteword, no commas needed. You get back a list.  "" create a string, you get back a single thing.

my $z=<<xyz{$x}def>>;
(xyz abc def)

is the same as
my $z=<<xyz $x def>>;
(xyz abc def)


So in this context "{$x}" means insert (interpolate) a
variable into the list?  I was thinking it meant to
insert a variable into a string.  Did saying <<>>
automatically tell Perl6 that this was a list
and not a sting?



 > my $x = "ab";
ab
 > my $z=<<xyz $x def>>;
(xyz ab def)
 > my $y = "xxy $x def";
xxy ab def
 > $z.WHAT
(List)
 > $y.WHAT
(Str)
 > my $q = ["xyz", $x, "def"];
[xyz ab def]
 > $q.WHAT
(Array)
 > my $r = ("xyz", $x, "def");
(xyz ab def)
 > $r.WHAT
(List)



Hi Andy,

I am confused.

<code>
#!/usr/bin/env perl6

my $v = "aa bb cc";
my $w = <<dd ee ff>>;
my $x = qw[ gg hh ii ];
my $y = "jj" ~ <<kk>> ~ "ll";
my $z = <<xx{$v}yy{$w}zz>>;

say "\$v is a ",$v.WHAT, "\t  $v";
say "\$w is a ",$w.WHAT, "\t  $w";
say "\$x is a ",$x.WHAT, "\t  $x";
say "\$y is a ",$y.WHAT, "\t  $y";
say "\$z is a ",$z.WHAT, "\t  $z";

</code>

$v is a (Str)     aa bb cc
$w is a (List)    dd ee ff
$x is a (List)    gg hh ii
$y is a (Str)     jjkkll
$z is a (List)    xx aa bb cc yy dd ee ff zz


Why is not $y a list as well?  Did <<>> switch back to being a ""
in this context?

And exactly what is a list?  It looks like an array represented as a
space delimited string.  Am I missing something?

And when is <<>> a "" and when is it not?

Thank you for the help!

-T

Reply via email to