On 10/5/18 6:28 PM, Brandon Allbery wrote:
You can't with that, because < ... > acts like single quotes; '@x' there is a string literal, not the list @x. If you use << ... >> then it act like double quotes, and will use the list instead.
I am sorry. With the top posting, I can't tell what you are talking about. I also can't tell which of the three question I asked that you are answering :'(
On Fri, Oct 5, 2018 at 9:23 PM ToddAndMargo via perl6-users <[email protected] <mailto:[email protected]>> wrote:On 10/5/18 6:09 PM, Brandon Allbery wrote: > That's where the | comes in. If you say > > my @b = (1, |@a, 2); > > then you get (1, 'a', 'b', 'c', 2) like in Perl 5. But you can specify > what gets flattened, so you can choose to flatten some arrays but not > others if you need to for some reason: > > my @b = (1, |@b, 2, @b, 3); > > gives you (1, 'a', 'b', 'c', 2, ('a', 'b', 'c'), 3). This often matters > in parameter lists, if you want one of the parameters to be the list > itself instead of it being spread across multiple parameters. In Perl 5 > you had to say \@b to pass a ref to the list instead, and the sub had to > know it was getting a scalar containing an arrayref and needed to > dereference it (if you don't know, don't ask; it's ugly). Am I correct in my assumption? A little off the question, but how do I address something inside a nested array? In the following, how do I get at the "b" $ p6 'my @x=<a b c>; my @y=<1 2 @x 3 4>; say @y; dd @y;' [1 2 @x 3 4] Array @y = [IntStr.new(1, "1"), IntStr.new(2, "2"), "\@x", IntStr.new(3, "3"), IntStr.new(4, "4")] Also, how do I flatten @y above? Thank you for the help! -T -- brandon s allbery kf8nh [email protected] <mailto:[email protected]>
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Computers are like air conditioners. They malfunction when you open windows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
