Front page | perl.perl6.language |
Postings from May 2005
Re: (1,(2,3),4)[2]
Thread Previous
|
Thread Next
From:
Autrijus Tang
Date:
May 11, 2005 16:04
Subject:
Re: (1,(2,3),4)[2]
Message ID:
20050511230448.GA21198@aut.dyndns.org
On Wed, May 11, 2005 at 03:00:15PM -0600, Luke Palmer wrote:
> On 5/11/05, Autrijus Tang <autrijus@autrijus.org> wrote:
> > In a somewhat related topic:
> >
> > pugs> (1,(2,3),4)[2]
> > 4
> >
> > Because the invocant to .[] assumes a Singular context.
>
> Right, but the *inside* of the invocant is still a list, so it's in
> list context. I think that line should return 3.
Okay. Here is the current (all-passing) t/data_types/nested_arrays.t:
{
my @a = (1,2,[3,4]);
my $a = (1,2,[3,4]);
my @b = [1,2,[3,4]];
my $b = [1,2,[3,4]];
my @c = (1,2,(3,4));
my $c = (1,2,(3,4));
my @d = [1,2,(3,4)];
my $d = [1,2,(3,4)];
is(+@a, 3, 'Array length, nested []');
is(+$a, 3, 'Array ref length, nested []');
is(+@b, 1, 'Array length, nested [], outer []s');
is(+$b, 3, 'Array ref length, nested [], outer []s');
is(+$c, 4, 'Array ref length, nested ()');
is(+@c, 4, 'Array length, nested ()');
is(+@d, 1, 'Array length, nested (), outer []s');
is(+$d, 4, 'Array ref length, nested (), outer []s');
}
Please sanity-check. :-)
Thanks,
/Autrijus/
Thread Previous
|
Thread Next