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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |