An array subscript will, by default, be evaluated in slice context.

Note that Perl 6 signature allow multi method dispatch that distinguishes between these two cases;

my @a = 1; my_sub(@a, 2); # and my_sub(1, 2);

This is possible because lists don't flatten in slice context. (Slice context is something like multi-dimensional list context).

So I know that @a[1] returns a single scalar value, the one that is stored in @a. @a[@other_list_with_many_values] will always produce a list, which is transformed to a capture (think reference here) in generic item context, and to the number of elements in numeric context.

I don't know what @a[@list_with_one_element] returns, but it seems logical that it returns a list as well. If you want it to return a single element, not a list, you can flatten the array:

@a[|@list_with_one_element];

In reply to Re: [Perl 6] single-value vs. array slices by moritz
in thread [Perl 6] single-value vs. array slices by John M. Dlugosz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.